我有两个目录'dir1'和'dir2',我想输出这两个目录的所有内容。所以,我使用bash命令'xargs'仅通过一个命令行来创建它。命令是“echo'1 2'| xargs -d''-I @ -t sh -c'cat dir @/*'”,但结果很奇怪。关于xargs和通配符的技巧
[[email protected] /data1/walter]$ echo '1 2' | xargs -d ' ' -I @ -t sh -c 'cat [email protected]/*'
sh -c cat dir1/* <<<< This output is normal
1 <<<< This is all content in dir1
sh -c cat dir2
/* <<<< these two lines are odd, it looks like xargs insert a '\n' between 'dir2' and '/*'
cat: dir2: Is a directory <<<< as a result, 'cat' can't receive argument 'dir2'
sh: line 1: /bin: is a directory <<<< and command line '/*' is error
尝试使用find dir *。你可以访问find的man页面来控制/格式化你想要的输出方式。 – Pratham 2014-09-02 12:48:57