Jester Jeffrey
Jester Jeffrey

Reputation: 115

Searching standard commands for a string

I'm trying to list all the standard commands that contain a certain string. I'm told echo $PATH will help with this but I'm not sure how... Any advice? Thanks in advance!

Upvotes: 1

Views: 43

Answers (3)

Perleone
Perleone

Reputation: 4038

All the "standard commands" will be located in /bin, /usr/bin, /sbin, /usr/sbin, /usr/local/bin, /usr/local/sbin, /usr/local/something/bin, etc. So all the commands have a "bin/" in front of them. Just let locate do its thing:

locate bin/ | grep -F 'whatever you are looking for'

Actually, /sbin and /usr/sbin will contain system commands. If you want to exclude those:

locate bin/ | grep -F sbin/ | grep -F 'whatever you are looking for'

All you want to know about the different bin and sbin directories can be found in the Filesystem Hierarchy Standard (FHS).

Upvotes: 0

twm
twm

Reputation: 1458

Try this:

find `echo $PATH | tr : ' ' ` | grep FOO

Where "FOO" is the string you're interested in.

And if you want to ignore case, use the -i flag for grep:

find `echo $PATH | tr : ' ' ` | grep -i FOO

Upvotes: 1

Anew
Anew

Reputation: 5502

ls `echo $PATH | tr ':' '\n'` | grep "string_to_search_for"

Upvotes: 0

Related Questions