On Mon, 14 Nov 2011, Mike Miller wrote: > On Mon, 14 Nov 2011, Florin Iucha wrote: > >> On Mon, Nov 14, 2011 at 01:18:39PM -0600, Mike Miller wrote: >> >>> This is a simple problem that I'm sure someone here can solve. I was >>> thinking about making the Roku aliases recommended in an earlier post. >>> These would all be two letters long beginning with 'r'. I wouldn't >>> want the new commands to interfer with anything that already exists, >>> but what's the best way to check? >>> >>> 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. By the way, backticks are now deprecated in Bash and we are supposed to use $() instead. It is actually much better because you can use nesting. Mike