查找目录中不是目录的所有文件

Ale*_*lex 35 unix bash ksh

我正在寻找一种方法来列出目录中的所有文件,不包括目录本身,以及这些子目录中的文件.

所以,如果我有:

./test.log
./test2.log
./directory
./directory/file2
Run Code Online (Sandbox Code Playgroud)

我想要一个返回的命令:./ test.log ./test2.log,没有别的.

Joh*_*ica 60

如果你想test.log,test2.log和file2则:

find . -type f
Run Code Online (Sandbox Code Playgroud)

如果您不想要file2:

find . -maxdepth 1 -type f
Run Code Online (Sandbox Code Playgroud)


ant*_*_rh 13

如果您还需要列出符号链接,管道,设备文件和文件系统的其他特定元素,则应使用:

find -maxdepth 1 -not -type d
Run Code Online (Sandbox Code Playgroud)

这将列出目录以外的所有内容.