Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Linux

วิธีแตกไฟล์ Zip ใน Linux

Zip files ไม่ common เท่าเดิมตอน download speeds ช้า และทุก saved byte matters อยู่ดี ยังคงเป็น fairly common file type ไม่นานมานี้จะต้องเปิดหนึ่งไฟล์

ขึ้นอยู่กับ distribution ที่ใช้ น่าจะแตก zip archive ได้ง่าย แตรู้ advanced ways เปิด zip files และ deal กับ contents ไม่ได้ทำให้เสียหาย

แตกไฟล์ Zip ด้วย GUI

บน Linux desktop environments ส่วนใหญ่ แตกไฟล์ง่าย คลิกขวาไฟล์เห็น options ปกติเห็น "Extract Here" หรือ "Unzip Here"

ยังเห็น "Extract To" location ใช้งานถ้าอยากแตกไฟล์จาก Downloads ไปที่อื่น Not every desktop environment มี shortcuts ติดตั้ง แต่ถ้ามี easiest method

ถ้า desktop ไมมี handy shortcuts เปิด zip file ใน GUI archive program ได้ รวม Gnome Archive Manager บน Gnome desktop, Ark บน KDE Desktop และอื่นๆ

ถ้าไม่มี GUI archive utility หรืออยาก powerful features ไป command line

แตกไฟล์ Zip ด้วย Command Line

Linux command-line utilities บางตัวมี arcane names แตกรณีนี้ไม่ใช่ คำสั่งแตกไฟล์ zip บน Linux เรียกว่า unzip อย่างง่าย

Simplest way แตกไฟล์ zip บน Linux command line รัน:

unzip filename.zip

จะแตกไฟล์ตรง directory ที่อยู่ ถ้าอยากแตกใน directory อื่น ทำได้ สมมติไฟล์ใน downloads อยากแตกใน home directory รัน:

unzip filename.zip -d ~

Preview เนื้อหา Zip File บน Command Line

บน desktop double-click zip file ดู contents ก่อนแตก บน command line ทำไม่ได้

แตไม่ได้หมายความว่าไม่ preview เนื้อหา zip file ได้ รัน:

unzip -l filename.zip

เนื้อหาไฟล์แสดงทีละบรรทัด

แตกบางส่วนของ Zip File เลือกได้

ตอน preview เนื้อหา zip file ได้ อาจรู้ว่าไม่ต้องการทุกอย่างในไฟล์ แทรกได้ 2 วิธี แตก 1-2 ไฟล์จาก zip archive หรือ exclude ไฟล์

แตก single file จาก zip archive ต้องระบุ full path ถ้ามี folder ชื่อ Folder มีทุกอย่าง ต้องระบุนี้

unzip filename.zip "Folder/file1.txt"

ถ้าอยากแตกไฟล์โดยไม่สร้าง directory ใหม่ ใช้ switch -j:

unzip -j filename.zip "Folder/file1.txt"

Exclude file ทำงานเหมือนกัน แตใช้ switch -x อยาก exclude "file.txt" รัน:

unzip filename.zip -x "Folder/file1.txt"

การบีบอัดไฟล์ ล่ะ?

ตอนรู้แตก zip files มาก แต่เพียง part ของ equation ต้องการส่ง items ไปให้เพื่อนหรือเพื่อนร่วมงาน wrapped ในไฟล์เดียว?

Compressing files ง่ายเท่าเปิด zip file แตอาจ complex มากกว่า อยากรู้เพิ่ม เรามี complete guide compressing และ archiving files บน Linux