Bash:ls * 没有文件夹分组

Aug*_*ger 15 linux ls

如果我输入:

ls source/*

source/fonts:
fontello

source/images:
bg1.png                eng.png        fra.png   
Run Code Online (Sandbox Code Playgroud)

我得到了按文件夹名称分组的文件列表。如何简单地获取文件名列表?

ls source/*

source/fonts/fontello
source/images/bg1.png
source/images/eng.png
source/images/fra.png   
Run Code Online (Sandbox Code Playgroud)

谢谢

max*_*xvw 14

不改变输出似乎是不可能的,但这里有一个简单的替代方法:

find source/ -type f
Run Code Online (Sandbox Code Playgroud)

或者(特定于 GNU find),只获取您问题中深度的文件:

find source/ -type f -mindepth 2 -maxdepth 2
Run Code Online (Sandbox Code Playgroud)

(或者,如果您想要像ls给您这样的目录,请删除-type f


小智 5

如果您添加一些迷幻药 ( ls -d),您可以简单地坚持使用 ls :

# mkdir test
# cd test
# mkdir A B C
# touch {A,B,C}/file*
# ls -d */*    
A/file  B/file  C/file
Run Code Online (Sandbox Code Playgroud)