The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
command line args skooly5 UNIX for Dummies Questions & Answers 2 04-06-2008 07:46 PM
Command line args enuenu High Level Programming 2 05-29-2007 12:19 AM
alias with args how to ... umen UNIX for Dummies Questions & Answers 4 12-28-2005 07:47 AM
required command line args yoi2hot4ya UNIX for Dummies Questions & Answers 6 06-02-2005 06:50 PM
Args to Array Shaz Shell Programming and Scripting 2 06-30-2003 04:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-06-2008
skooly5 skooly5 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 14
command line args 2

I have this while loop and at the end I am trying to get it to tell me the last argument I entered. And with it like this all I get is the sentence with no value for $1. Now I tried moving done after the sentence and it printed the value of $1 after every number. I don't want that I just want the last argument entered.



while [ $# -gt 0 ]
do
echo "$#"
shift
sleep 1s
done

echo The last command line argument you entered is $1.

can anyone help?
  #2 (permalink)  
Old 04-06-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,913
Try the following ...

Code:
while [ $# -gt 1 ]
do
    echo "$#"
    shift
    sleep 1s
done

echo The last command line argument you entered is $1.
  #3 (permalink)  
Old 04-06-2008
skooly5 skooly5 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 14
that worked except now when it counts down it stops at 2.
5
4
3
2

The last command line you entered is $1.

Can I get the 1 back? So it reads

5
4
3
2
1

The last command line you entered is $!.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0