find 排除子目录

find 排除子目录的方法有很多,不过下面这个很强大。

[nobody@oc8243606638 tkt]$  find . ! -name "." -type d -prune -o -type f -name "*.txt" -print
./IN3930738.txt
./IN3913493.txt
./IN3958279.txt
./IN3939424.txt
./IN3785781.txt
[nobody@oc8243606638 tkt]$ find . -name "*.txt" | head -5
./RPM/IN3329198.txt
./RPM/IN3353027.txt
./RPM/IN3247452.txt
./RPM/IN3242594.txt

maxdepth的写法:

[nobody@oc8243606638 tkt]$ find . -maxdepth 1 -name '*.txt'
./IN3930738.txt
./IN3913493.txt
./IN3958279.txt
./IN3939424.txt
./IN3785781.txt

你可能感兴趣的:(find 排除子目录)