./zips/
a.zip - contains bla.txt , cla.txt
b.zip - contains bla.txt, cla.txt
c.zip - contains somethingelse.txt, this.xls
d.zip - contains bla.txt
... - ...
需要在文件夹 /tmp/ 中输出
a_bla.txt
a_cla.txt
b_bla.txt
b_cla.txt
c_somethingelse.txt
c_this.xls
Tried mkdir tmp
for f in *.zip; do unzip "$f" -d tmp && mv tmp/* "${f%.zip}.txt"; done
rmdir tmp
答案1
尝试:
for zip in *.zip; do bsdtar -xvf "$zip" -C /tmp -"s/^/${zip%.zip}_/"; done