001、
(base) [email protected]:/home/test2# ls ## 当前目录下三个文件夹 test1 test2 test3 (base) [email protected]:/home/test2# tree ## 使用tree命令查看 . ├── test1 │ ├── 1.txt │ ├── 2.txt │ └── 3.txt ├── test2 │ ├── 1.csv │ ├── 2.csv │ └── 3.csv └── test3 ├── 1.map ├── 2.map └── 3.map 3 directories, 9 files (base) [email protected]:/home/test2# for i in `ls`; do ls $i/* |xargs >> /home/collective.txt; done ## 利用for循环遍历,xargs转换为一行,并输出至指定文件夹 (base) [email protected]:/home/test2# cat /home/collective.txt ## 查看结果 test1/1.txt test1/2.txt test1/3.txt test2/1.csv test2/2.csv test2/3.csv test3/1.map test3/2.map test3/3.map