Linux zip命令:添加具有不同名称的文件 [英] Linux zip command: add a file with different name

查看:160
本文介绍了Linux zip命令:添加具有不同名称的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在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\\\
@=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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆