john smith wrote: > > hi, > > I am having some problems creating some sample scripts...hoping that > somebody can lend a helping hand. > > #!/bin/sh > if test -x $1 > then whoami; > echo $1 > fi > > Yes I know my script sucks but I'm just learning..anyway, my questions are: > > 1. my script doesn't seem to display the script name together with > whoami..actually, what the script was supposed to do is when it is invoked, > it will display the user name together with the scriptname should the > scriptname gets changed somehow..it displays the username but not the > scriptname itself.
The name of the script is $0. $1 is the first argument. > 2. how do I add to this script the count of the number of lines in a file? > i.e. let's say cat's man page. man wc. > 3.lastly,let's say I want to print the first line of each 3-char.h file in > /usr/include/lib..how can I accomplish this? I'm not sure what you're asking exactly. Perhaps something like for i in *.h; do this; do that; do the other thing; done See 'man bash'. for name [ in word ] ; do list ; done See also 'man head'. > and Yes, this is part of my assignment I hope I still left something to the imagination... -Ron- GPG and other info at: http://www.yellowbank.com/