我为工作创建了 200 个 zip 文件,但我意识到我忘记将 .txt 添加到每个文件中。与其花费数小时重做这项工作,我更希望得到任何帮助。
有没有人知道使用 bash 可以解压缩、添加 .txt 文件并重新压缩所有 200 个文件的方法?.txt 文件的名称不会只更改 .zip 文件。
谢谢你。
pLu*_*umo 15
您甚至不需要解压缩文件,您可以更新现有文件:
zip -u existing.zip file.txt
Run Code Online (Sandbox Code Playgroud)
从zip手册:
update (-u)
Update existing entries if newer on the file system and add new files.
If the archive does not exist issue warning then create a new archive.
Run Code Online (Sandbox Code Playgroud)
如果要添加完整文件夹,请添加-r.
要更新多个 zip 文件,请执行以下操作:
for z in *.zip; do
zip -u "$z" file.txt
done
Run Code Online (Sandbox Code Playgroud)
请参阅U&L 上的此相关问题。