Simple shellscript help please - reading parameters and checking whether the first is a directory
Posted on 2004-08-22
Ok, my objective is as follows:
Write a fully commented bourne shell script program that outputs how many parameters were given on the command line, if there is more than one parameter given the program should report to the user if the first parameter exists as a directory or not.
this is the shellscript so far:
echo "The number of parameters you entered was $#"
if [ -d $1 ]
echo "The first parameter you entered is a directory"
echo "The first parameter you entered is not a directory"
Problem: when i run the shellscript program if always gives me "0" as the number of entered parameters, and always says "the first parameter you entered is a directory" even when the directory doesn't exist, so clearly this isn't working,
any help on this matter appreciated, thanks alot, seremaz