1
Ubuntu$ ls -1
文件1文件2为什么是ls -1 | xargs -I {} echo -n {} {} {}不按正确的顺序打印?
Ubuntu$ ls -1 | xargs -I{} echo -n {}{}{}
file1file1file1file2file2file2
为什么我没有拿到结果的顺序?:file1file2file1file2file1fil2
Ubuntu$ ls -1
文件1文件2为什么是ls -1 | xargs -I {} echo -n {} {} {}不按正确的顺序打印?
Ubuntu$ ls -1 | xargs -I{} echo -n {}{}{}
file1file1file1file2file2file2
为什么我没有拿到结果的顺序?:file1file2file1file2file1fil2
因为xargs
在每个单词执行命令(echo
)其输入。当然,{}
每次都是一样的。即使你重复了很多次。
你可以做你想要使用的是什么for
:使用的
ls=$(ls -1)
for i in {1..3}
do
echo $ls
done
例子:
$ mkdir d ; cd d
<d>$ touch file1 file2 file3
<d>$ ls=$(ls -1)
<d>$ for i in {1..3}
> do
> echo $ls
> done
file1 file2 file3
file1 file2 file3
file1 file2 file3
如果你提供更多的信息,你可能会得到更具体的答案。 – Thor 2012-07-26 18:35:17