小编The*_*hop的帖子

递归列出目录中的所有文件,但排除目录本身

一个简单的问题,我正在运行以下 find 命令:

find . -type d \( -path ./.git -o   \
                  -path ./log -o    \
                  -path ./public -o \
                  -path ./tmp       \) \
                  -prune -o         \
                  -print
Run Code Online (Sandbox Code Playgroud)

列出我目录中的所有文件,不包括指定目录。

这很好用,但是,我还想做的是从输出中排除任何实际目录,因此如果有如下目录结构:

test
  -- foo.text
  -- bar.text
Run Code Online (Sandbox Code Playgroud)

当我运行我的命令时,我想看到:

./test/foo.text
./test/bar.text
Run Code Online (Sandbox Code Playgroud)

代替:

.
./test
./test/foo.text
./test/bar.text
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

linux find search file-search

10
推荐指数
2
解决办法
5万
查看次数

标签 统计

file-search ×1

find ×1

linux ×1

search ×1