Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 如何从存档中仅提取一种文件?_Shell_Terminal_Unzip_Unrar - Fatal编程技术网

Shell 如何从存档中仅提取一种文件?

Shell 如何从存档中仅提取一种文件?,shell,terminal,unzip,unrar,Shell,Terminal,Unzip,Unrar,给定一个.zip或.rar归档文件,其中包含10个文件,每个文件具有不同的扩展名 因为我只想要其中的.jpg文件 如何在不提取其他9个文件的情况下提取其中的*.jpg?尝试以下方法: unzip test.zip '*.jpg' 文件名后的参数是要提取的文件。见: 您可以使用: while read -r f; do tar -xf "$zipFile" "$f" done < <(tar tf "$zipFile" | grep '\.jpg') 读取时-rf;做 ta

给定一个.zip或.rar归档文件,其中包含10个文件,每个文件具有不同的扩展名

因为我只想要其中的.jpg文件

如何在不提取其他9个文件的情况下提取其中的*.jpg?

尝试以下方法:

unzip test.zip '*.jpg'
文件名后的参数是要提取的文件。见:

您可以使用:

while read -r f; do
    tar -xf "$zipFile" "$f"
done < <(tar tf "$zipFile" | grep '\.jpg')
读取时-rf;做
tar-xf“$zipFile”$f

完成<似乎答案就在附近。实际上部分完成了:
tar -xf test.tar --wildcards --no-anchored '*.jpg'
while read -r f; do
    tar -xf "$zipFile" "$f"
done < <(tar tf "$zipFile" | grep '\.jpg')