Command-line arguments: Difference between revisions
Content added Content deleted
(initial - blank page) |
(Filled out task, added example.) |
||
Line 1: | Line 1: | ||
{{Programming Task}} |
|||
to do |
|||
Retrieve the list of command-line arguments given to the program. |
|||
Example command line: |
|||
myprogram -c "alpha beta" -h "gamma" |
|||
==[[UNIX Shell]]== |
|||
===[[sh]]=== |
|||
To retrieve the entire list of arguments: |
|||
WHOLELIST="$@" |
|||
To retrieve the second and fifth arguments: |
|||
SECOND=$2 |
|||
FIFTH=$5 |
Revision as of 15:15, 13 February 2007
Retrieve the list of command-line arguments given to the program.
Example command line:
myprogram -c "alpha beta" -h "gamma"
UNIX Shell
sh
To retrieve the entire list of arguments:
WHOLELIST="$@"
To retrieve the second and fifth arguments:
SECOND=$2 FIFTH=$5