Linux zip命令:添加具有不同名称的文件 [英] Linux zip command: add a file with different name
问题描述
我想在zip文件中添加一个不同名称的文件,并避免创建具有所需名称的新文件。例如,我想将myfile.txt文件添加到zip,但将其重命名为myfile2.txt。
感谢
您可以使用zipnote zip包。
首先使用myfile.txt文件创建zip存档:
zip archive.zip myfile.txt
然后将zip文件中的myfile.txt重命名为:
printf@ myfile.txt\\\
@=myfile2.txt\\\
| zipnote -w archive.zip
(感谢而不是 echo -e
。 / users / 648658 / jens> Jens
@ myfile.txt\\\
的简短说明:/ p>
@=myfile2.txt\\\
从 zipnote -h
:@ name后面可以加上@ = newname
并且 \\\
分隔这两个命令。
I´d like to add a file in a zip file, with a different name, and avoiding the creation of a new file with the desired name. For example, I´d like to add the myfile.txt file to a zip, but renaming it to myfile2.txt.
Thanks
You can use zipnote which should come with the zip package.
First build the zip archive with the myfile.txt file:
zip archive.zip myfile.txt
Then rename myfile.txt inside the zip archive with:
printf "@ myfile.txt\n@=myfile2.txt\n" | zipnote -w archive.zip
(Thanks to Jens for suggesting printf
instead of echo -e
.)
A short explanation of "@ myfile.txt\n@=myfile2.txt\n"
:
From zipnote -h
: "@ name" can be followed by an "@=newname" line to change the name
And \n
separates the two commands.
这篇关于Linux zip命令:添加具有不同名称的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!