Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-26-2004, 12:49 PM   #1
LQ Newbie
Registered: Apr 2004
Posts: 3

Rep: Reputation: 0
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]
echo $number
sleep 1
let $# ="$number - 1"
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 do you get the last??
thanks a lot..
Old 04-26-2004, 01:27 PM   #2
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110

while test $# -gt 0 ; do
	echo $#
echo "Last argument: $ARG"


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
processing command args in bash slzckboy Programming 16 10-18-2017 04:12 AM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 08:45 PM
51 characters only in the 1st Line of command line eggCover Linux - General 2 07-29-2004 02:28 PM
Bash script; command and args in variable. magjo813 Programming 2 02-16-2004 10:22 AM
>>> control mplayer with command args??? nibjb Linux - Software 0 07-17-2003 12:09 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:09 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration