Command line arguments

Andrew DeFaria
Wed Oct 31 19:16:00 GMT 2012

On 10/31/2012 11:23 AM, Brian Wilson wrote:
> If you have a script (e.g. and you wish to pass arguments to the
> script, your command line should look like " arg1 arg2 arg3..."  The
> number of arguments will be correct and you will be able to access them as
> ${1}, ${2}, etc.  Also, you may want to read up on the getopts command as a
> way to process command line arguments.
Technically, the {}'s are not needed. You can access them with $1, $2, 
etc. Most special characters sever as delimiters too so you can refer to 
them as "This the $1 parameter" or even "/path/to/$1/dir". But if you 
wanted to do something like this - "This is the ${1}parameter" or even 
"/path/to/$" but not "/path/to/$1save/dir" you'd need the {} 
(i.e. "/path/to/${1}save/dir" because otherwise the shell would be 
looking for "1save" as an env variable name.
Andrew DeFaria <>
Fear has its use but cowardice has none. - Mohandas Gandhi

Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list