2

That's an unusual question. Let's say I have one command with this synopsis:

/usr/bin/wc [-c | -m | -C] 

and second command with

head [-number | -n number] [filename]

The question is how many different usage variations(combinations) of these commands can I get? And what are they?

I'm new to UNIX and I'm trying to understand command syntax in general. This question is a part of my "homework" and I'm confused. A friend of mine told me that the answer of a second (head) command is 6. So there should be 6 variations and my guess is that they are

head 
head -number
head -n number
head filename
head -number filename
head -n number filename

Is this correct? If so, does a " | " sign between -number and -n number means "or" so that both of them should not be used together? Thanks for your answers.

1 Answers1

2

Yes.

[-a|-b] means "either -a or -b, but not both, and both are optional".

[-a][-b] would mean "both -a and -b may occur, but both are optional".

-a b would mean "-a is a required option with a required option-argument b".

The standard wc utility looks like

wc [-c|-m] [-lw] [file...]

-c and -m are mutually exclusive, but both are optional. -l can be used with -w (and/or with one of -c or -m), but these are also optional. There may be zero or many additional files.

Kusalananda
  • 333,661