[NBLUG/talk] Shell Script

Troy Arnold fryman at sonic.net
Mon Mar 8 10:32:01 PST 2004


On Mon, Mar 08, 2004 at 08:10:32AM -0800, Ian Sutherland wrote:
> This worked; 	#!/bin/bash
> 		ls /usr/bin /usr/X11R/bin | less
> 
> Can it be done with $* or $@?
> 
> Thanks, Ian

Hey, Ian-

Your question is pretty durn ambiguous.  I *think* you want to show a
list of all the possible commands you can type at a shell prompt.  If
this is correct, then try:

IFS=':';for dir in $PATH; do /bin/ls ${dir}; done

This lists all the files in all the dirs in your $PATH environment
variable.

The only thing a little different about this is that it sets the IFS
(Internal Field Separator, normally '[newline][space][Tab]'
variable to a colon, so that bash will interpret each component of $PATH
as a separate word.

This script is dumb, it will print everything, whether it is executable
or not -- but it's short :)


-troy




More information about the talk mailing list