如何从档案中只提取一种文件?
答
试试这个:
unzip test.zip '*.jpg'
在文件名后的参数是要提取的文件。见man unzip
Arguments section:
[file(s)] An optional list of archive members to be processed, separated by spaces. (VMS versions compiled with VMSCLI defined must delimit files with commas instead. See -v in OPTIONS below.) Regular expressions (wildcards) may be used to match multiple members; see above. Again, **be sure to quote expressions that would otherwise be expanded** or modified by the operating system.
答
tar -xf test.tar --wildcards --no-anchored '*.jpg'
答
您可以使用:
while read -r f; do
tar -xf "$zipFile" "$f"
done < <(tar tf "$zipFile" | grep '\.jpg')
似乎答案是就在附近。 – Hugolpz
实际上部分做到了:http://stackoverflow.com/questions/9356849/ – Hugolpz