'find' (command) finds nothing with -wholename

邮差的信 提交于 2019-12-11 10:54:44

问题


Why does this command work:

/home/user1/tmp $ find ./../.. -wholename '.*/tmp/file.c' -exec echo '{}' \;
./../../user2/tmp/file.c
/home/user1/tmp $

And this command does not work? (finds nothing)

/home/user1/tmp $ find /home -wholename '.*/tmp/file.c' -exec echo '{}' \;
/home/user1/tmp $

回答1:


The first command generates file names starting with ./../... Thus the wholename pattern will match because they start with ..

The second command generates filenames starting with /home. However, the wholename pattern is still looking for paths starting with . which will not match any file in this case.

Note that patterns are not regular expressions. If you were expecting them, look at the -regex option instead.



来源:https://stackoverflow.com/questions/30820977/find-command-finds-nothing-with-wholename

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!