LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   locate a commnad (https://www.linuxquestions.org/questions/linux-software-2/locate-a-commnad-313029/)

zchoyt 04-13-2005 10:46 PM

locate a commnad
 
I have run updatedb

then I type locate "mount"

it gives me a list of everypath with mount in it. Is there a way to find just the command mount without all the extra junk?


Zakk

Linux.tar.gz 04-13-2005 10:52 PM

whereis

zchoyt 04-13-2005 11:02 PM

Couple of questions about that.
1. Do you need to run a command like updatedb first?
2. It also seems to spit out more than one output. Are these depenancies or something?

I'm checking out the man page right now.

JLTB 04-13-2005 11:08 PM

Hey zchoyt,

Here's what I do,

run 'updatedb' (you did that) then use locate but pipe the output to less, or better yet
'grep' it first. Grep is the super geeky unix program that lets you search for patterns within strings (ok, maybe its not that geeky). It will allow you to filter the output a bit. 'less' is a program that displays output in such a way that you can scroll up and down through it to read it all (kinda like a really simple readonly text editor).

something like 'locate mount|grep bin|less' will look for everything on your computer with mount in it, then only display the results that ALSO had 'bin' in them, then display it all in less so you can read it before it whizzes past your eyes.

There are some good tutorials around as well, try something like 'grep tutorial' or 'locate tutorial' in Google.

zchoyt 04-13-2005 11:18 PM

Cool, thankx for the tips. I am getting used to linux env still. I did know about those commands but didn't think about using them together like that. It worked pretty well.

heema 04-14-2005 05:56 AM

you should check out linux's commands as it makes life a hole lot easier

http://www.linuxcommand.org/

rpz 04-14-2005 06:12 AM

locate bin/mount will also work. grep is not needed. The 'which' command will tell you the program that is actually run with a command, even if it's aliased or whatever. It does not use the locatedb but uses the environment (e.g. PATH).

JLTB 04-14-2005 02:18 PM

Good point rpz, that is more efficient.


All times are GMT -5. The time now is 02:26 AM.