non recursive find
The find
command is recursive by default. Let's say you want to find all the screen shots on your ~/Desktop
, but ignore any screens in the directories in Desktop. Setting the maxdepth
flag will tell how far to recurse, using the value 1
only searches the directory you specified, using 2
would go into each directory, but only not search any sub directories, and so on.
#this will recurse by default
$ find ~/Desktop -name "*Screen*"
#this will only search the Desktop and it's immediate subdirectories
$ find ~/Desktop -maxdepth 2 -name "*Screen*"
Tweet