unzip
เรียกใช้คำสั่ง unzip
[code]
unzip <filename>.zip
[/code]
unrar
ติดตั้ง package unrar
[code]
sudo apt-get install unrar
[/code]
เรียกใช้คำสั่ง unrar
[code]
unrar x <filename>.rar
[/code]
ที่มา: FileCompression, ubuntuforums.org
unzip
เรียกใช้คำสั่ง unzip
[code]
unzip <filename>.zip
[/code]
unrar
ติดตั้ง package unrar
[code]
sudo apt-get install unrar
[/code]
เรียกใช้คำสั่ง unrar
[code]
unrar x <filename>.rar
[/code]
ที่มา: FileCompression, ubuntuforums.org
การเรียกใช้ command line จาก Python สามารถเรียกได้โดยใช้คำสั่ง popen
import os
ipFile = “ip.txt”
opFile = “op.txt”
cmd = ‘swath <%s> %s’ % (ipFile, opFile)
f = os.popen(cmd)
หรือใช้ Popen
import subprocess
subprocess.Popen([r”gzip”,”-d”, “x.txt.gz”]).wait()
ที่มา: Subprocess management, Making System Calls in Perl and Python
ตัวอย่างไฟล์งานชื่อ test
วิธีรวมเป็นไฟล์เดียว
tar -cvf test.tar test
ผลลัพธ์จะได้ไฟล์ test.tar
วิธี zip
gzip test.tar
ผลลัพธ์จะได้ไฟล์ test.tar.gz
วิธี unzip
tar -zxvf test.tar.gz
ผลลัพธ์จะได้ไฟล์ test
อ้างอิง expert2you.com