我喜欢使用 bzip 来压缩文件,因为它会删除原始文件并保留新文件。
如何使用 7zip 压缩文件并在压缩完成后删除原始文件?
答案1
p7zip 似乎在解压后就删除了档案。
改用 7za。它附带“p7zip-full”包。
例如, :
$ apt-get 安装 p7zip-full
$ 7za 和 abc.7z
答案2
sudo apt-get install p7zip
p7zip <filename>
压缩它(它不会留下原始文件)p7zip -d <filename>.7z
解压缩
示例运行:
~/Temp$ ls -ltrh
total 4.0K
-rwxrwxr-x 1 thefourtheye thefourtheye 851 Jun 18 20:22 TestIP.sh
~/Temp$ p7zip TestIP.sh
7-Zip (A) [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=en_IN,Utf16=on,HugeFiles=on,2 CPUs)
Scanning
Creating archive TestIP.sh.7z
Compressing TestIP.sh
Everything is Ok
~/Temp$ ls -ltrh
total 4.0K
-rw-rw-r-- 1 thefourtheye thefourtheye 567 Jun 20 08:53 TestIP.sh.7z
~/Temp$ p7zip -d TestIP.sh.7z
7-Zip (A) [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=en_IN,Utf16=on,HugeFiles=on,2 CPUs)
Processing archive: TestIP.sh.7z
Extracting TestIP.sh
Everything is Ok
Size: 851
Compressed: 567
~/Temp$ ls -ltrh
total 4.0K
-rwxrwxr-x 1 thefourtheye thefourtheye 851 Jun 18 20:22 TestIP.sh