On Mon, 14 Nov 2011, Florin Iucha wrote:

> On Mon, Nov 14, 2011 at 02:11:54PM -0600, Mike Miller wrote:
>>>>> If I go to the command prompt and type r[TAB] I see a list of 174
>>>>> options for completion, but some are directories and many consist
>>>>> of more than two characters.  It looks like "rm" is the only
>>>>> two-character command beginning with "r", but what I want is a
>>>>> simple command that lists all of the two-character commands in my
>>>>> path that begin with "r". How can I get that list?
>>>>
>>>>   for pp in `echo $PATH | tr ":" "\n"`; do ls $pp | grep '^r.\>' ; done
>>>
>>> There has to be a better way!  ;-)  I could do it with a for loop but
>>> was hoping for something more direct, maybe using "find".
>>>
>>> Also, that doesn't guarantee that the file is executable.  It would
>>> also be good to see the path to the file instead of just the filename.
>>
>> Example:
>>
>> $ for DIR in $(echo $PATH | tr : '\n') ; do find "$DIR" -name 'r?' -type f -executable ; done
>> /bin/rm
>>
>> But I was hoping for something more concise.
>
>   find $(echo $PATH | tr : '\n') -name 'r?' -type f -executable


Ha!  I beat you to it by 1 minute.  ;-)

Mike