|
KSH Script Assistance
Hey everyone, I'm newer than new when it comes to this ksh and scripting stuff, and unix in general. I have been thrown into a task at work that
A: They expect me to come up to speed on,
B: Show I can do this. (Program for the workgroup)
Here's the script, part of it, from the overall script:
if [ $# -eq 1 ]; then
echo "the files that exist...... ...."
FILEDIR="$1"
elif [ $# -eq 2 ]; then
echo "The files exist in $1/$2..... .... "
FILEDIR="$1"
SUBDIR="$2"
else
echo "Script help text"
echo "script filedir [subdir]
echo " "
exit 1
fi.
OK, here's what I know/understand:
I can type the script name, followed by one or 2 paramaters that it will see, and work on. Or, if no parameters are entered, we get that help screen. So far, so .. so.
I also see where $1 and $2 are assigned to parameters or variables, depending on when they are typed.
My task (At the moment) is to add a '-h' option to bring up the help text rather than let it run when no parameters are supplied. I don't know or have figured out how, despite reading through a few books today because I'm not sure what I am looking for precisely.
My first issue is I do not understand the '$#' or the '-eq'.
My second issue is how deep can if's be nested? (If that's where I need to go with this one.)
Any help would be appreciated. AND If anyone can point me to good resources on the web to review or learn from for future reference? I need to learn what I'm looking at so I don't have to ask help for what seems to be simple questions.
Thanks!
Last edited by Brusimm; 05-09-2007 at 04:54 AM..
|