get n-variable parameters in bash
Hi,
I've a script that it's invoked with n-variable parameters. Here's an examples: Code:
./myprogram.sh inputdir FIELD1 FIELD2 ... FIELDN outputfile How can I do that in bash? |
You can try the shift statement inside a loop to cycle through all the positional parameters (arguments) independently from their number, e.g.
Code:
until [[ -z $1 ]] |
I've found it.
The command getopt worked for me. |
Given a command line:
Code:
prompt$ verb option1 option2 ... optionN You access them within your bash script as:
Code:
prompt$ man bash Within less, type "/Positional" to search for that string. If you have more than nine space-separated options, there is a built-in command, 'shift' to drag more options into place. Again 'man bash' is your friend. The value of $0 is actually the full file path and name to the running script. So if you are running a script named "framis" that is stored in "/usr/local/bin", the verb will appear as "/usr/local/bin/framis". Bonne chance, ~~~ 0;-Dan |
Quote:
Code:
echo ${10} |
All times are GMT -5. The time now is 08:41 AM. |