I keep having to do a “man find” (LOL @ man find) to refresh my memory when looking for specific files. Here are some easy to remember tips on find and locate:

FIND:

A simple find / -type f -name "" would do the trick if you know exact filename.

find / -type f -iname "filename*" if you want to match more files.

Avoid -type option if you want to search for directories etc. See manual of find for more information. To see the manual, issue the command:

man find

 

LOCATE:

locate is much more faster than find since it just searches through a database(s) of indexed locations to find your file/regex.

Example:

locate some-file.avi searches through a database(s) that is maintained of almost every file on the disk, for a file called “some-file.avi”

locate -i "some-file.avi" will ignore the case of the file you are searching for.

locate -i "*.txt" will display a list of location of all the files with *.txt extension on your system.

man locate for more info on the file..

You might need to run updatedb first to ensure the index database is up to date, otherwise, ‘locate’ might not return what you are looking for.

 

Reference:
http://askubuntu.com/questions/89393/how-to-search-entire-hard-drive-for-a-file

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s