linux - 如何在不包含文件夹本身的情况下查找文件夹中的所有文件

标签 linux shell find

我尝试了以下命令:

>> ls abc
1  2  3
>> find abc -name "*" -print0
abcabc/1abc/2abc/3
>> find abc -name "*" -print0 | xargs -0 ls
abc/1  abc/2  abc/3

abc:
1  2  3

如果我使用*,find似乎也找到了.。我们可以要求 find 不返回 . 吗?

我还尝试了-not -path "."。它不起作用。

最佳答案

您可以指定相对于您指定的起点的最小深度:

$ cd -- "$(mktemp --directory)"
$ mkdir a
$ touch a/b a/c
$ find a -mindepth 1 -name "*"
a/c
a/b

关于linux - 如何在不包含文件夹本身的情况下查找文件夹中的所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44850210/

相关文章:

linux - 内核模块中的总线设备回显 'file exists' 错误

linux - 为 SSH 远程命令全局配置 PATH

regex - 为什么 sed 不像 awk 那样追加换行符?

linux - 使用 awk 计算另一个文件中模式出现的次数

python - 如何在Python中从shell中获取变量?

node.js - 通过 ssh2 Nodejs 执行 shell 命令

python - 按行计算匹配某些规则的两个字符之间的大文件中的总字节数

linux - 在 Linux 中为每个文件查找和 tar

linux - 列出文件夹中的基本文件,其中包含文件的多个日期戳版本

java - 在 ArrayList 中查找数组的索引