bash 如何使用 Putty 解压当前目录中的所有 tar 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25123651/
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
How to untar all tar files in current directory using Putty
提问by yesco1
How can I untar all tar files in one command using Putty.
如何使用 Putty 在一个命令中解压所有 tar 文件。
I Tried the following but its not un-tarring (all files start with alcatelS*)
我尝试了以下但它没有解压(所有文件都以 alcatelS* 开头)
tar -xfv alcatelS*.tar
It is not working i don't get no errors and it is not un-tarring. Thank you,
它不起作用,我没有得到任何错误,也没有解焦。谢谢,
回答by konsolebox
-xfv
is wrong since v
is being referred as the file instead. Also, tar
can't accept multiple files to extract at once. Perhaps -M
can be used but it's a little stubborn when I tried it. Also, it would be difficult to pass multiple arguments that were extracted from pathname expansion i.e. you have to do tar -xvM -f file1.tar -f file2.tar
.
-xfv
是错误的,因为v
它被称为文件。此外,tar
不能接受同时提取多个文件。也许-M
可以用,但我尝试的时候有点固执。此外,很难传递从路径名扩展中提取的多个参数,即您必须执行tar -xvM -f file1.tar -f file2.tar
.
Do this instead:
改为这样做:
for F in alcatelS*.tar; do
tar -xvf "$F"
done
Or one-line: (EDIT: Sorry that -is- a "one"-liner but I find that not technically a real one-liner, just a condensed one so I should haven't referred to that as a one-liner. Avoid the wrong convention.)
或单行:(编辑:抱歉,这是一个“单行”,但我发现这在技术上不是真正的单行,只是一个浓缩的,所以我不应该将其称为单行。避免错误的约定。)
for F in alcatelS*.tar; do tar -xvf "$F"; done
回答by Vahid
You can use following command for extract all tar.gz files in directory in unix
您可以使用以下命令提取 unix 目录中的所有 tar.gz 文件
find . -name 'alcatelS*.tar.gz' -exec tar -xvf {} \;