仅在一行中列出所有文件夹名称

仅在一行中列出所有文件夹名称

如何在同一行中列出所有文件夹名称:因为,我尝试过:

ls $workspace

我明白了

parm
shell
sql

但我希望最终结果如下:

parm shell sql

笔记

我正在詹金斯作业的脚本窗口中编写此命令。命令结果应保存在名为“folder1.txt”的文件中,因此原始命令是:

ls $WORKSPACE --ignore={"Jenkinsfile",".gitignore",".editorconfig","branches.txt","folders.txt"} > folder1.txt

我也尝试过:

ls -1 $WORKSPACE --ignore={"Jenkinsfile",".gitignore",".editorconfig","branches.txt","folders.txt"} > folder1.txt

但是folder1.txt中给出的命令结果是

parm
shell
sql

答案1

降低-1

$ ls $workspace --ignore={"Jenkinsfile",".gitignore",".editorconfig","branches.txt","folders.txt"}
parm  shell  sql

-1专门制作 ls list one file per line

如果您将ls输出重定向到文件使用-C选项:

ls -C  $workspace --ignore={"Jenkinsfile",".gitignore",".editorconfig","branches.txt","folders.txt"}  > list

相关内容