![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| List certain file in a folder and make list | andrisetia | UNIX for Dummies Questions & Answers | 1 | 09-15-2008 02:21 PM |
| How to read arguments to make command | vikashtulsiyan | Shell Programming and Scripting | 3 | 06-12-2008 05:35 AM |
| i want to list all command line arguments except | naree | Shell Programming and Scripting | 3 | 03-31-2008 12:11 PM |
| Bash Shell - # of arguments | DNAx86 | Shell Programming and Scripting | 1 | 01-10-2008 01:23 PM |
| Make new arguments for echo command | Panteras | Shell Programming and Scripting | 0 | 11-29-2007 03:43 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Make a list in bash out of arguments
Hello, I have a very stupid/simple problem, but for some reason I cannot figure out...and I need your help! I am writting a bash scrip that should be executed using "my_script X Y Z T" where X Y Z and T can be any string, but there can be any number of arguments. I want my script to do a list from these inputs: Code:
#!/bin/bash i=1 while [ $i -le $# ] do list=$list" ./myfile."$i i=`expr $i + 1` done echo $list Using the above script, I got: ./myfile.1 ./myfile.2 ./myfile.3 ./myfile.4 instead of: ./myfile.X ./myfile.Y ./myfile.Z ./myfile.T Thanks for your help |
|
||||
|
Thanks for your answer!!
I will try that right now. However, there is one more thing: in reality I want to skip the first argument. I know I can use a "if" condition so that if $i == 1, then I do nothing. Is there a nicer way to force the "for" loop to start with i=2 ? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|