![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Password cannot be circular shift of logonid | sag71155 | HP-UX | 2 | 05-09-2008 02:04 AM |
| Regarding the shift command??? | shrao | Shell Programming and Scripting | 2 | 03-31-2007 12:39 AM |
| Bit shift operator | naan | High Level Programming | 5 | 09-07-2006 11:13 PM |
| shift command | Nisha | Shell Programming and Scripting | 6 | 07-19-2002 02:54 AM |
| xterm SHIFT crazy | oneivan | UNIX for Dummies Questions & Answers | 2 | 06-05-2002 01:29 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
shift command
There is an error when i am trying to use the shift command in this way:
($1 = -d, $2 = 123, $3 = -c etc etc) for $arg in $@ do case $arg in "-d") shift; (so that the $2 will become the $arg now) (and while it loop the 2nd time,) ($arg will become $3 which is -c) ;; done Anyone know how can i do that? |
| Forum Sponsor | ||
|
|
|
||||
|
Your for statement is already stepping though the args. Don't use "shift" at all in your loop and it should work.
In your previous thread, I showed you: for parm ; do echo $parm is a parameter done This will work exactly the same as: for parm in "$@" ; do echo $parm is a parameter done But you left the quotes off with your loop. If you have a parameter list like: ./script one 222 "333 3333" 4444 that third parameter will be split in two pieces with your loop. You will also have trouble with a null parameter: ./script one 222 "" 4444 To use shift, one way is while [ $# -gt 0 ] ; do echo $1 is a parm shift done |
||||
| Google The UNIX and Linux Forums |