bash 如何在 Ubuntu 中一次提取文件夹中的多个 7z 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4273576/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 19:53:46  来源:igfitidea点击:

How can I extract multiple 7z files in folder at once in Ubuntu?

bashubuntuextract7zip

提问by Robert Cardona

How can I extract about 900 7z files which are all located in the same folder (all have only one file inside) without doing it one by one?

如何提取大约 900 个 7z 文件,它们都位于同一文件夹中(都只有一个文件),而无需一一提取?

I am using Ubuntu 10.10. All files are located in /home/username/folder1/folder2.

我正在使用 Ubuntu 10.10。所有文件都位于/home/username/folder1/folder2.

采纳答案by Ignacio Vazquez-Abrams

for arc in *.7z
do
  7zwhatever "$arc"
done

回答by Santosh Pillai

7za -y x "*.7z" 

The above code worked for me

上面的代码对我有用

回答by Matt Joiner

for f in *.7z
do
    7zr e "$f" &
done

This will extract all .7zfiles if they're 7z format to the current directory, without waiting for completion.

这会将所有.7z7z 格式的文件提取到当前目录,而无需等待完成。

Your computer could be owned. You have been warned!

您的计算机可能已被拥有。你被警告了!

回答by Ruslan Prokopchuk

Using parallelis rather convenient way with total progress meter for free ;)

使用并行是一种相当方便的方式,可以免费使用总进度表;)

ls *.7z | parallel -j+0 --eta '7z x {} >/dev/null'

回答by pzyxian

7z x "*.7z"this worked for me in ubuntu

7z x "*.7z"这在 ubuntu 中对我有用

回答by Franck Dernoncourt

If you wish to extract multiple 7zip archives to folders with the same names in Linux, you can use:

如果您希望在 Linux 中将多个 7zip 存档解压缩到具有相同名称的文件夹中,您可以使用:

for archive in *.7z; do 7z x -o"`basename \"$archive\" .7z`" "$archive"; done

For example, if you have two 7zip archives a.7zand b.7z, it will create two folders aand b, and uncompress a.7zinto folder aand b.7zinto folder b.

例如,如果您有两个 7zip 档案a.7zand b.7z,它将创建两个文件夹aand b,并解压缩a.7z到文件夹ab.7z文件夹中b

The above command comes from this answer on superuserby user Vojtech.

上面的命令来自用户Vojtech对超级用户的回答

回答by zappee

You do not need to overcomplicate things. To extract a 7-Zip archive split to multiply parts use the following command:

你不需要把事情复杂化。要提取 7-Zip 存档拆分以将多个部分相乘,请使用以下命令:

7z x archive.7zip.0

7-Zip will notice you that you have a multi-volume archive and it unpacks everything.

7-Zip 会注意到您有一个多卷存档,它会解压所有内容。

回答by hhafez

in adition to using a for loop

除了使用 for 循环

you can also use find in combination with the exec argument or xargs

您还可以将 find 与 exec 参数或 xargs 结合使用

回答by M Tarmiz

The simplest way is unzip '*.zip'.

最简单的方法是unzip '*.zip'

Make sure you have the 'marks.

确保你有'标记。