LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Can someone give me tips on using the 'locate' command - with examples? (http://www.linuxquestions.org/questions/linux-general-1/can-someone-give-me-tips-on-using-the-%27locate%27-command-with-examples-934115/)

LinusStallman 03-12-2012 05:51 PM

Can someone give me tips on using the 'locate' command - with examples?
 
Hi.

Can someone give me tips on using the 'locate' command - with examples?

Thanks in advance.

I know this so far:

Code:

# -i means not case sensitive
Code:

locate -i searchstring
Code:

locate -i stuff.txt
Also what is the deal with mlocate?

acid_kewpie 03-12-2012 05:57 PM

what's to explain? That's all I know about it, and the manpage is pretty self explanatory. You really need to ask specific questions, rather than expecting to be taught.

ignore the name mlocate, it's just a different implementation of the same service. M = merging with the updatedb tool.

LinusStallman 03-13-2012 07:09 AM

Quote:

Originally Posted by acid_kewpie (Post 4625153)
what's to explain? That's all I know about it, and the manpage is pretty self explanatory. You really need to ask specific questions, rather than expecting to be taught.

ignore the name mlocate, it's just a different implementation of the same service. M = merging with the updatedb tool.

I was just looking for a few quick examples.

acid_kewpie 03-13-2012 07:47 AM

locate myfile

locate anotherfile

locate athirdfile

;-)

salasi 03-13-2012 10:18 AM

Additional note;

'locate' can also be combined with 'grep' (ok, that should be obvious), to useful effect;

So, eg, if what you know is that the file that you are looking for, you probably stored in your downloads directory and it probably was a pdf file

locate downloads | grep -i pdf

might get you closer. Still not close enough? Well, let's say it also concerned ubuntu, maybe

locate downloads | grep -i pdf |grep -i ubuntu

is the thing that gets you there. More than that ought to be an application of similar principles and possibly a careful reading of the man page. Anything really clever, and you'll probably need 'find' instead.


All times are GMT -5. The time now is 04:31 AM.