Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Aug 2011
Order of command parameters/arguments
So Ive seen different things when it comes to command arguments, sometimes people use a "-" before or after the parameter letter and sometimes not. Why is this?
Also how do I find out if the order of the parameter matters? Is this in the man pages?
Depends on the implementation.
For example, a simple bash script takes arguments only in a defined order, also called positional parameter.
Here, three arguments are given to bashscript.sh
#bashscript.sh 1 A file
Inside bashscript.sh, $1 has the value 1, $2 is A, $3 is file.
This works. But a more sophisticated approach is to use getopt
You will notice, that e.g. the order of arguments does not matter anymore.
And yes. In doubt, a man page will tell how a tool shall be used.You must always face the curtain with a bow.