ค้นหาเว็บไซต์

Dtrx - เครื่องมือแยกไฟล์อัจฉริยะ (tar, zip, cpio, rpm, deb, rar) สำหรับ Linux


เราทุกคนอาจเผชิญกับสถานการณ์ ณ จุดใดเวลาหนึ่งในขณะที่ใช้คำสั่ง Linux tar.gz, tar.bz2, tbz . ไฟล์เก็บถาวรหลายประเภท มีคำสั่งมากมายที่ต้องจำ... ต้องขอบคุณเครื่องมือ dtrx อีกต่อไปแล้ว

  1. 18 คำสั่ง Tar เพื่อสร้างและแตกไฟล์เก็บถาวรใน Linux
  2. วิธีเปิด แยก และสร้างไฟล์ RAR ใน Linux

Dtrx คืออะไร?

Dtrx ย่อมาจาก “Do The Right Extraction“ เป็นโอเพ่นซอร์สและแอปพลิเคชันบรรทัดคำสั่งที่มีประสิทธิภาพมากสำหรับระบบ *nix ที่ทำให้งานการแยกไฟล์เก็บถาวรของคุณง่ายขึ้น

คำสั่ง dtrx เป็นการแทนที่คำสั่ง “tar -zxvf” หรือ “tar -xjf” และมีคำสั่งเดียวในการแตกไฟล์เก็บถาวร ในรูปแบบต่างๆ มากมาย รวมถึง tar, zip, rpm, deb, gem , 7z, cpio, rar และอื่นๆ อีกมากมาย นอกจากนี้ยังสามารถใช้เพื่อขยายขนาดไฟล์ที่บีบอัดด้วย bzip2, gzip ฯลฯ

ตามค่าเริ่มต้น dtrx แยกเนื้อหาไปยังไดเร็กทอรีเฉพาะและแก้ไขปัญหาสิทธิ์ (เช่น สิทธิ์ถูกปฏิเสธ) ที่ผู้ใช้เผชิญขณะแยกเนื้อหาเพื่อให้แน่ใจว่าเจ้าของสามารถอ่านและเขียนทั้งหมดได้ ไฟล์เหล่านั้น

คุณสมบัติของ Dtrx

  1. จัดการไฟล์เก็บถาวรหลายประเภท: มีคำสั่งง่ายๆ เพียงคำสั่งเดียวในการแตกไฟล์ tar, zip, rar, gz, bz2, xz, rpm, deb, gem, ไฟล์ zip ที่ขยายในตัว และไฟล์ exe รูปแบบอื่น ๆ อีกมากมาย .
  2. จัดระเบียบทุกอย่าง: จะแยกไฟล์เก็บถาวรลงในไดเร็กทอรีเฉพาะของตนเอง
  3. สิทธิ์ที่มีเหตุผล: นอกจากนี้ยังช่วยให้แน่ใจว่าผู้ใช้สามารถอ่านและเขียนไฟล์เหล่านั้นทั้งหมดได้หลังจากการแตกไฟล์ โดยยังคงสิทธิ์เดิมไว้
  4. การแยกแบบเรียกซ้ำ: สามารถค้นหาไฟล์เก็บถาวรภายในไฟล์เก็บถาวรและแยกไฟล์เหล่านั้นด้วย

วิธีการติดตั้ง Dtrx ใน Linux

ตามค่าเริ่มต้นแล้ว เครื่องมือ dtrx จะรวมอยู่ในที่เก็บ Ubuntu สิ่งที่คุณต้องทำคือ apt-get ง่ายๆ เพื่อติดตั้งในระบบของคุณ

บน Debian/Ubuntu/Linux Mint

sudo apt-get install dtrx

บน RHEL/CentOS/Fedora

บนระบบที่ใช้ Red Hat dtrx ไม่สามารถใช้งานได้ผ่านที่เก็บเริ่มต้น คุณต้องดาวน์โหลดสคริปต์ dtrx และติดตั้งโปรแกรมทั่วทั้งระบบโดยใช้คำสั่งด้านล่างในฐานะผู้ใช้ root

wget http://brettcsmith.org/2007/dtrx/dtrx-7.1.tar.gz
tar -xvf dtrx-7.1.tar.gz 
cd dtrx-7.1
python setup.py install --prefix=/usr/local
ผลลัพธ์ตัวอย่าง
running install
running build
running build_scripts
creating build
creating build/scripts-2.6
copying and adjusting scripts/dtrx -> build/scripts-2.6
changing mode of build/scripts-2.6/dtrx from 644 to 755
running install_scripts
copying build/scripts-2.6/dtrx -> /usr/local/bin
changing mode of /usr/local/bin/dtrx to 755
running install_egg_info
Creating /usr/local/lib/python2.6/site-packages/
Writing /usr/local/lib/python2.6/site-packages/dtrx-7.1-py2.6.egg-info

วิธีใช้คำสั่ง dtrx

คำสั่ง dtrx นั้นเหมือนกับวงแหวนวงเดียวที่ใช้ควบคุมพวกมันทั้งหมดใน ลอร์ดออฟเดอะริงส์ แทนที่จะต้องจำไวยากรณ์สำหรับแต่ละไฟล์เก็บถาวร สิ่งเดียวที่คุณต้องจำคือคำสั่ง dtrx

1. แยกไฟล์เก็บถาวรเดี่ยว

ตัวอย่างเช่น ฉันต้องการแยกไฟล์เก็บถาวรชื่อ “tecmint27-12-2013.gz“ ฉันดำเนินการเฉพาะคำสั่ง dtrx โดยไม่ต้องใช้แฟล็กใดๆ

[root@tecmint]# dtrx tecmint27-12-2013.gz

นอกเหนือจากการทำให้การแตกไฟล์ง่ายขึ้น มันมีตัวเลือกอื่น ๆ มากมาย เช่น การแตกไฟล์ไปยังโฟลเดอร์ และการแยกไฟล์เก็บถาวรอื่น ๆ ทั้งหมดซ้ำ ๆ ภายในไฟล์เก็บถาวรที่กำหนด

2. แยกไฟล์เก็บถาวรหลายรายการ

พิจารณาว่าคุณมีไฟล์ “dtrAll.zip“ ซึ่งประกอบด้วย dtr1.zip, dtr2.zip และ dtr3.zip< แต่ละอันประกอบด้วย dtr1,dtr2 และ dtr3 ตามลำดับ แทนที่จะต้องแตกไฟล์ dtrAll zip ด้วยตนเองก่อน แล้วจึงแตกไฟล์ dtr1, dtr2 และ dtr3 แต่ละตัว คุณสามารถแตกไฟล์ลงในโฟลเดอร์ที่เกี่ยวข้องได้โดยตรงโดยใช้ dtrx และโดยการเลือกตัวเลือก “a“ มันจะแยกไฟล์ zip ทั้งหมดแบบวนซ้ำ

[root@tecmint]# dtrx dtrAll.zip
ผลลัพธ์ตัวอย่าง
dtrx: WARNING: extracting /root/dtrAll.zip to dtrAll.1
dtrAll.zip contains 3 other archive file(s), out of 3 file(s) total.
You can:
 * _A_lways extract included archives during this session
 * extract included archives this _O_nce
 * choose _N_ot to extract included archives this once
 * ne_V_er extract included archives during this session
 * _L_ist included archives
What do you want to do?  (a/o/N/v/l) a

หลังจากการแตกไฟล์ เนื้อหาของไดเร็กทอรีที่แตกออกมาสามารถตรวจสอบได้โดยใช้คำสั่ง ls

[root@tecmint]# cd dtrAll
[root@tecmint]# ls 

dtr1  dtr1.zip  dtr2  dtr2.zip  dtr3  dtr3.zip

3. การแยกไฟล์เก็บถาวรเฉพาะ

สมมติว่าคุณต้องการแยกไฟล์เก็บถาวรแรกและไม่ใช่ไฟล์เก็บถาวรภายใน เมื่อเลือก N จะเป็นการแยกเฉพาะไฟล์เก็บถาวรที่กำหนด ไม่รวมไฟล์เก็บถาวรอื่นที่อยู่ภายใน

[root@tecmint]# dtrx dtrAll.zip
ผลลัพธ์ตัวอย่าง
dtrx: WARNING: extracting /root/dtrAll.zip to dtrAll.1
dtrAll.zip contains 3 other archive file(s), out of 3 file(s) total.
You can:
 * _A_lways extract included archives during this session
 * extract included archives this _O_nce
 * choose _N_ot to extract included archives this once
 * ne_V_er extract included archives during this session
 * _L_ist included archives
What do you want to do?  (a/o/N/v/l) N

เนื้อหาของไดเร็กทอรีที่แตกออกมาสามารถตรวจสอบได้โดยใช้คำสั่ง ls ดังที่แสดง

[root@tecmint]# cd dtrAll
[root@tecmint]# ls

dtr1.zip dtr2.zip dtr3.zip

4. แยกแต่ละเลเยอร์ของไฟล์เก็บถาวร

หากต้องการแยกแต่ละเลเยอร์ของไฟล์เก็บถาวรภายในไฟล์เก็บถาวรเป็นกรณี ๆ ไป เช่น หากคุณต้องการแตกไฟล์เก็บถาวรในเลเยอร์ที่ 2 แต่ไม่ใช่เลเยอร์ที่ 3 คุณสามารถใช้ตัวเลือก “o

พิจารณาว่าคุณมีไฟล์ zip “dtrNewAll.zip“ ซึ่งมี “dtrAll.zip” และ “dtrNew” เป็นเนื้อหา ตอนนี้ถ้าคุณต้องการแยกเนื้อหาของ “dtrNewAll” และ “dtrAll” ด้วย แต่ไม่ใช่ของ dtr1.zip, dtr2 .zip และ dtr3.zip คุณสามารถใช้ตัวเลือก “o” และ “n” ดังที่แสดงด้านล่าง

dtrx dtrNewAll.zip
ผลลัพธ์ตัวอย่าง
dtrNewAll.zip contains 1 other archive file(s), out of 2 file(s) total.
You can:
 * _A_lways extract included archives during this session
 * extract included archives this _O_nce
 * choose _N_ot to extract included archives this once
 * ne_V_er extract included archives during this session
 * _L_ist included archives
What do you want to do?  (a/o/N/v/l) o
dtrAll.zip contains 3 other archive file(s), out of 3 file(s) total.
You can:
 * _A_lways extract included archives during this session
 * extract included archives this _O_nce
 * choose _N_ot to extract included archives this once
 * ne_V_er extract included archives during this session
 * _L_ist included archives
What do you want to do?  (a/o/N/v/l) n

เนื้อหาของไดเร็กทอรีที่แตกออกมาสามารถตรวจสอบได้โดยใช้คำสั่ง ls ดังที่แสดง

[root@tecmint]# cd dtrNewAll
[root@tecmint]# ls

dtrAll  dtrAll.zip  dtrNew
[root@tecmint]# cd dtrAll
[root@tecmint]# ls

dtr1.zip dtr2.zip dtr3.zip

ก่อนอื่นเราเลือกตัวเลือก “o” ซึ่งหมายความว่าไฟล์เก็บถาวรทั้งหมดภายใน dtrNewAll จะถูกแยกออกมา ต่อมาเราเลือกตัวเลือก “n” สำหรับ dtrAll.zip ซึ่งหมายความว่าไฟล์เก็บถาวรที่อยู่ภายใน dtr1.zip , dtr2.zip และ dtr3.zip จะไม่ถูกแตกออกมา

5. แยกข้อมูลเมตาออกจากไฟล์ .deb, .rpm และ .gem

ตัวเลือก “-m” จะแยกข้อมูลเมตาจากไฟล์เก็บถาวร .deb, .rpm และ .gem แทนที่จะเป็นเนื้อหาปกติ นี่คือตัวอย่างของคำสั่ง

[root@tecmint]# dtrx -m openfire_3.8.2_all.deb 
[root@tecmint]# dtrx -m openfire-3.8.2-1.i386.rpm
[root@tecmint]# ls

conffiles  control  md5sums  postinst  postrm  prerm

มีตัวเลือก dtrx อีกมากมายให้สำรวจ เพียงเรียกใช้ “dtrx –help” เพื่อแสดงตัวเลือกที่มี

[root@tecmint]# dtrx  --help

Usage: dtrx [options] archive [archive2 ...]

Intelligent archive extractor

Options:
  --version             	show program's version number and exit
  -h, --help            	show this help message and exit
  -l, -t, --list, --table      	list contents of archives on standard output
  -m, --metadata        	extract metadata from a .deb/.gem
  -r, --recursive       	extract archives contained in the ones listed
  -n, --noninteractive  	don't ask how to handle special cases
  -o, --overwrite       	overwrite any existing target output
  -f, --flat, --no-directory    extract everything to the current directory
  -v, --verbose         	be verbose/print debugging information
  -q, --quiet           	suppress warning/error messages

ลิงค์อ้างอิง

หน้าแรกของ dtrx

ฉันคิดว่าคุณต้องลองใช้ dtrx เนื่องจากเป็นเครื่องมือบรรทัดคำสั่งเดียวที่มีประสิทธิภาพที่ให้คำสั่งเดียวในการคลายการบีบอัดไฟล์เก็บถาวรทุกรูปแบบ เพียงเท่านี้และอย่าลืมทิ้งบันทึกของคุณไว้ในส่วนความคิดเห็น