command line args in a countdown
I need to write a shell script that will take the number of command line arguments and count them down (like 6 5 4 3 2 1) then tell you the last command line argument that the user entered. It says to count them down using a shift builtin in a loop. I am unsure how to do this. I have used the while command and cannot get that to work. Here is my script for the while....
let $# = number
while ["$number" - ge 1]
do
echo $number
sleep 1
let $# ="$number - 1"
done
echo the last command line argument you entered was $1
do I have to let $# = number or can I just use $# ? I have tried both ways and cannot get them to work....or am I doing the wrong thing completely?
also, this gives the first command line arg....how do you get the last??
thanks a lot..
|