Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a script and in the usage() function I want to specify the usage. My script uses either option1 or option2 or both. One of them is mandatory.

Is there a standard way to write it up?

share|improve this question
up vote 5 down vote accepted

If you talk about simplest usage information optional parameters are listed in [].

For example usage section from man:

usage: man [-adfhktwW] [section] [-M path] [-P pager] [-S list]
    [-m system] [-p string] name ...

So if your script can accept option1 and option2 but they aren't mandatory you can display it like this:

script [option1] [option2]
share|improve this answer
Actually one of them is mandatory. – abc Mar 6 '12 at 2:21
So it should be without [] – pbm Mar 6 '12 at 6:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.