The -path
parameter allows to specify a pattern to match the path of the result. The pattern can match also the name itself.
To find only files containing log
anywhere in their path (folder or name):
find . -type f -path '*log*'
To find only files within a folder called log
(on any level):
find . -type f -path '*/log/*'
To find only files within a folder called log
or data
:
find . -type f -path '*/log/*' -o -path '*/data/*'
To find all files except the ones contained in a folder called bin
:
find . -type f -not -path '*/bin/*'
To find all file all files except the ones contained in a folder called bin
or log files:
find . -type f -not -path '*log' -not -path '*/bin/*'