Hello I am very new to shell and I bought some books and trying to learn it. I started trying to write a script that will take a number and count it down to 1 with commas in between. This number can only be one argument. If lower than one or higher than one argument it sends an error message.
Here is an example of the output:
input: countdown.sh 8
output: 8,7,6,5,4,3,2,1
input: countdown.sh 8 2
output: error: program must be executed with one argument.
Here is what I have so far. I am stuck because I am not sure how you differentiate between arguments and values.
Any help would be appreciated.
#!/bin/ksh
###############
# Script name: countdown.sh
# Case #1: ./countdown.sh <integer>
###########
# Assign the first command line argument to the variable NUMBER.
NUMBER=$1
# One argument must be provided, otherwise don't execute
if [$NUMBER > 1]
then
echo �error: program must be executed with 1 argument.�
exit .....
elif [ $NUMBER=1]
while [ $NUMBER -gt 0 ]
do
printf .......
if [$NUMBER -gt 1 ]
then
printf ", "
fi
NUMBER=$(($NUMBER - 1))
done
printf