|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Just cannot get this script right
I did fine o my first script i wrote
but this one I can not seem to get it right? This is what I am suppose to do??Write a shell script named showparms which will disp1ay each positional parameter from the shell command line (including $0), as well as the argument count $# and the entire set of command line parameters $@. Your script should display as many positional parameters as there are arguments, but if there are more than nine arguments on the command line display only the first nine positional parameters ($1 through $9). In either case, $@ should show all of the arguments. Be sure to include appropriate comments in your script so I will know what your script is doing. Each parameter should be displayed on a separate line which shows the parameter name and has the parameter value delimited by the angle brackets < and > so that it will be possible to see an argument which consists of a null string () or a blank space or spaces ( ). As an example:$ showparms 3 a b c Dec 15 Your ouput should be like this: $# = 5 $0 = <showparms> $1 = <3> $2 = < > $3 = <a b c> $4 = <> $5 = <Dec 15> $@ = <3 a b c Dec 15> The $@ is a list of all arguments. When displaying the value for $@, make sure you can account for all of the space characters which are displayed. There should not be too few or too many. In the example above, there is one space between each of the command line arguments, one additional space for the parameter $2 since it is and no additional spaces for the parameter $4 since it is . Execute your script with a command line of fewer than nine arguments and a command line of more than nine arguments. When there are fewer than nine arguments you should only display as many positional parameters as there are arguments. For example, if there are four arguments you should not display the $5 argument. IF there are more than nine arguments then you should not try to display $10 since there is no such thing! Thank ![]() |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Just cannot get this script right |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|