seremaz
asked on
Creating a BSH which outputs the number of parameters on the command line
I Need to create a bourne shell script program that outputs how many parameters were given on the command line, and if there was one or more parameters given the program should report to the user if the first parameter exists as a directory or not.
Any help or nudge in the right direction? thanks alot.
Any help or nudge in the right direction? thanks alot.
$# gives the number of command line parameters. $1, $2, etc. are the first, second, etc. arguments
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if test -d $1
to check if first parameter is directory
to check if first parameter is directory
remove the "test" .. anyway lemmec posted the correct answer
ASKER
thats great, how would i first check how many parameters were given, and if this is greater than one THEN report if the first parameter is a directory?
Use nested ifs. Is this homework?
ASKER
this is a small base to a piece of coursework, the main coursework itself is creating a large test plan and test issues for the program, thankyou for your help
You are welcome. But is a 'B' grading justified?
ASKER
of course, as i said this is the base for the main test plan so as long as i'm on the right lines ill be fine... i just needed to be on the right line, and you put me there, thanks again :-) you've been a large help