Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, 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? ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2011
    Posts
    11

    Order of command parameters/arguments


    Hi all,
    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?

    Thanks,

    Erin

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,392
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •