让我们创建一个包含大量单个.txt
文件的目录。我的目的是在目录中查找单个文件,分别以相同的名称(不包括.txt)压缩它们,然后删除原始文件。
gzip
如下所示,它非常易于使用:
find .* -type f | xargs gzip
但我需要压缩文件。
注意:我没有sudo权限
来自人:
-m --move Move the specified files into the zip archive; actually, this deletes the target directories/files after making the specified zip archive. If a directory becomes empty after removal of the files, the directory is also removed. No deletions are done until zip has created the archive without error. This is use- ful for conserving disk space, but is potentially dangerous so it is recommended to use it in combination with -T to test the archive before removing all input files.
压缩当前目录中的ann文件
zip -m test.zip *.txt
试试这个,
for i in *.txt;
do
zip -m "${i%.*}.zip" "${i%.*}".*;
done
上面的代码将以.txt作为扩展名的所有文件在for循环中使用其前缀名称压缩每个文件...
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句