I need to add a part to a shell script that will count down the number of command line arguments, printing one per second to the screen and reporting how many command line arguments are left (e.g., by using the shift
builtin in a loop). So the screen would do a countdown 6 5 4 3 2 1 (if I had entered six command line arguments).
Also, when the last command line argument has been reached (shifted over to $1), the program will tell the user the value of the command line argument in a statement such as "The last command line argument that you entered is ______ . (whatever its value was is to be printed there.)
So far I have this code, but it only prints the first argument, and it doesn't print the numbers.
while read -n 1 -p "Press Enter to Continue.." key do if [ "$key" = '' ]; then sleep $# shift $1 echo "The last command line parameter you entered at the command line was: $1" break else echo "no key was pressed" fi done
What am I doing wrong? What should I do to fix it?