我想找到以_peaks.bed
结尾的文件,但不包括tmp
和scripts
文件夹中的文件.
我的命令是这样的:
find . -type f \( -name "*_peaks.bed" ! -name "*tmp*" ! -name "*scripts*" \)
但没用.tmp
和script
文件夹中的文件仍将显示.
有人对此有 idea 吗?
我想找到以_peaks.bed
结尾的文件,但不包括tmp
和scripts
文件夹中的文件.
我的命令是这样的:
find . -type f \( -name "*_peaks.bed" ! -name "*tmp*" ! -name "*scripts*" \)
但没用.tmp
和script
文件夹中的文件仍将显示.
有人对此有 idea 吗?
以下是使用find
指定的方法:
find . -type f -name "*_peaks.bed" ! -path "./tmp/*" ! -path "./scripts/*"
Explanation:
find .
-从当前工作目录开始查找(默认为递归)-type f
-将结果中只需要文件指定为find
-name "*_peaks.bed"
-查找以_peaks.bed
结尾的文件! -path "./tmp/*"
-排除路径以./tmp/
开头的所有结果! -path "./scripts/*"
-还排除路径以./scripts/
开头的所有结果Testing the Solution:
$ mkdir a b c d e
$ touch a/1 b/2 c/3 d/4 e/5 e/a e/b
$ find . -type f ! -path "./a/*" ! -path "./b/*"
./d/4
./c/3
./e/a
./e/b
./e/5
很接近,-name
选项只考虑basename,而as -path
考虑整个路径=)