在kshshell中,使用FIND搜索符号链接,但忽略某些目录

在kshshell中,使用FIND搜索符号链接,但忽略某些目录,shell,unix,find,ksh,Shell,Unix,Find,Ksh,我正在尝试在文件系统中搜索*.csv文件。我正在浏览的某些目录中有一些符号链接,但我想忽略某些目录,因为它们会导致令人讨厌的长时间消耗周期 find -L "location" -name "*.csv >> find_result.txt 我如何告诉find忽略某些目录,同时继续查看其他目录中的符号链接 find dir -wholename dirtoskip -prune -o [rest of your find command] 或 使用-prune告诉find不要进入

我正在尝试在文件系统中搜索*.csv文件。我正在浏览的某些目录中有一些符号链接,但我想忽略某些目录,因为它们会导致令人讨厌的长时间消耗周期

find -L "location" -name "*.csv >> find_result.txt
我如何告诉find忽略某些目录,同时继续查看其他目录中的符号链接

find dir -wholename dirtoskip -prune -o [rest of your find command]


使用
-prune
告诉
find
不要进入给定目录。例如:

find -L location -name 'dontLookHere' -prune \
              -o -name 'orThereEither' -prune \
              -o -name '*.csv' -print

我使用了find/usr/abc-L-name./ignore_dir'-prune-o-name“*.csv”-print>>myfiles.txt,但它仍然给我一条错误消息,告诉我find:bad option-L。可以同时使用-L和prune吗?@user1035818-必须将-L放在第一位,因为它是一个选项,而不是谓词。修复了上面的问题。另外,
-name
使用一个简单的文件名;如果要在特定的pthaname(如“/ignore_dir”)上进行修剪,但要继续并向下进入任何其他恰好命名为“ignore_dir”的目录,请改用
-path
。使用path不起作用,改用-name“*dirname*”。感谢您的回复,最终使它工作起来可能很好,只是它不遵循符号链接,但是
-wholename
的可移植性不如
-path
,因为与前者相比,更多版本的find(1)支持后者。(尽管仍有一些旧版本不支持任何一个…)
find -L location -name 'dontLookHere' -prune \
              -o -name 'orThereEither' -prune \
              -o -name '*.csv' -print