Posted by: Anonymous Coward
on October 31, 2005 08:00 PM
Sometimes you may want to exclude parts of the directory tree. It took me a while to figure out how to do this because it isn't very intuitive. If you wanted to search for foo.txt but don't want to descend into<nobr> <wbr></nobr>/proc or<nobr> <wbr></nobr>/dev you can do this find / -path '/proc' -prune -o -path '/dev' -prune -o -name foo.txt
The '-o' means 'or', so there in this case there are three conditions, separated by 'or', which will cause find to take action. The first two is when the path is '/proc' or '/dev' the action find will take is to prune them from the search path. The third condition is when the name is foo.txt. In this case find will print, since no other action is specified.
How to things from the search path
Posted by: Anonymous Coward on October 31, 2005 08:00 PMIf you wanted to search for foo.txt but don't want to descend into<nobr> <wbr></nobr>/proc or<nobr> <wbr></nobr>/dev you can do this
find / -path '/proc' -prune -o -path '/dev' -prune -o -name foo.txt
The '-o' means 'or', so there in this case there are three conditions, separated by 'or', which will cause find to take action. The first two is when the path is '/proc' or '/dev' the action find will take is to prune them from the search path. The third condition is when the name is foo.txt. In this case find will print, since no other action is specified.
See man find for more info.
#