Wednesday, August 30, 2006

 

locate command in Linux

find is pretty complex with lots of option when you just want to know where a file exists and whether it exists, you can then use locate, it is cool ...

say you are looking for a file xyz.xyz, you just type
locate xyz.xyz or locate x*.x* and boom you get the exact of path of all matching files

some usefull options in locats command

The -q option would suppress any other error messages as well

$ locate "*.dat" -q
You could use the -n option to limit the number of returned results to a specific number. E.g. you could ask for only 10 search results by the following command

$ locate "*.c" -n 10
This would return the first 10 files that end in .c that Linux finds.

You could use the -i option in case you wanted to perform a case insensitive search. The case of the filenames would not be considered

$ locate INDEX.HTML -i

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?