[英]Add zip files from one archive to another using command line
I have two zip archives. 我有两个zip档案。 Say,
set1
has 10 csv files created using Mac OS X 10.5.8 compress
option, and set2
has 4 csv files similarly created. 假设
set1
有10个使用Mac OS X 10.5.8 compress
选项创建的csv文件, set2
有4个类似创建的csv文件。 I want to take the 4 files from zipped archive set2
and add them to list of files in archive set1
. 我想从压缩存档
set2
提取4个文件,并将它们添加到存档set1
中的文件列表中。 Is there a way I can do that? 有没有办法可以做到这一点?
I tried the following in Terminal: 我在终端机中尝试了以下方法:
zip set1.zip set2.zip
This adds the whole archive set2.zip
to set1.zip
, ie, in set1.zip
now I have: 这将整个存档
set2.zip
添加到set1.zip
,即在set1.zip
我现在有:
file1.csv, file2.csv,..., file10.csv, set2.zip
What I instead want is: 我想要的是:
file1.csv, file2.csv,..., file10.csv, file11.csv, ..., file14.csv
where, set2.zip
is the archive containing file11.csv, ..., file14.csv
. 其中,
set2.zip
是包含file11.csv, ..., file14.csv
的存档。
Thanks. 谢谢。
unzip set2.zip -d .tmpdir; cd .tmpdir; zip ../set1.zip *; cd ..; rm -r .tmpdir;
This script here should do it. 这个脚本应该在这里做。
zipjoin.sh zipjoin.sh
#!/bin/bash
#Example: ./zipjoin.sh merge_into.zip merge_from.zip
mkdir .tmp
unzip $2 -d .tmp
zip $1 .tmp/*
rm -r .tmp
Hope that helps! 希望有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.