因为tar命令的格式是tar [options] [files to
extract],tar后面可以跟多个文件名作参数,但参数含义不是tar包的文件名,而是需要解压的tar包中的文件名。

如果tar要支持解压多个文件,还需保留上述功能,可能要实现成这样
    tar -f tar1 [options for tar1] [files in tar1] -f tar2 [options for
tar2] [files in tar2]

参数解析不是一般的麻烦,而且这种命令行格式,还需要根据参数的先后顺序决定含义,又增加了参数解析复杂度。

2010/8/5 User <[email protected]>

>
>
> 2010-08-05(Thursday) 19:22:09 +0800, Quinn Li <[email protected]>:
>
> > 可以用xargs组合
> >
> > ls *.tar.gz | xargs -n 1 tar xzf
>
>
>  多谢您的好办法。真的想不通为何 tar 不能同时操作多个文件。
>
>
>
> --
> To UNSUBSCRIBE, email to [email protected]
> with a subject of "unsubscribe". Trouble? Contact
> [email protected]
> Archive:
> http://lists.debian.org/[email protected]
>
>


-- 
Qin Li

回复