How to use find command to search files or directories
If you want to search files within your account home directory
find ~/ -name 'thefilename.txt'
or some part of the file name using wildcard characters
find ~/ -name '*file*.txt'
this command will search within home directory and all sub directories, if you omit ~/ it will search within current directory and the sub directories.
To search and ignore case-sensitivity you can use -iname flag
find -iname 'TheFileName.txt'
If you want to search directories only or files only, you can use -type flag
this will search files only
find -iname '*FileName*' -type f
this will search directories only
find -iname '*FileNam*' -type d
To exclude directories or a specific directory you can use -prune flag.
for example if we want to search note.txt and want to exclude a directory named myDir within home directory.
find ~/ -type d -iname 'mydir' -prune -o -name 'note.txt'
and if you want to exclude myDir1, myDir2, myDir3, you can use
find ~/ -type d -iname 'mydir*' -prune -o -name 'note.txt'
Hope this helps. Thanks for reading.
More..