There are a number of general guidelines to follow when running
utilities:
- An option may be followed by another option after a single
dash (-) on the command line as long as each preceding
option doesn't have an option argument.
For example, the option string -abc is equivalent to
-a -b -c. However, if -a accepts
an option argument, then -abc would be equivalent to
-a bc instead.
- Options and their option arguments should be specified with
spacing as shown in their documentation. If the documentation
says:
-n number
the number should be a separate command-line
argument from the -n. But if the documentation
refers to:
-nnumber
then number should appear in the same argument as
-n without any intervening blanks. Utilities in
QNX and in POSIX-conforming systems permit both forms
in all utilities unless otherwise stated, but you'll achieve the
greatest portability by using the preferred
form. This is particularly important when developing scripts
that may be used on multiple (QNX and non-QNX) platforms.
- Options are usually listed in alphabetical order, but
there's no restriction on the order that they may appear
in the command line when used, unless otherwise
indicated in the documentation for the utility.
Note that in some utilities, mutually exclusive options
override each other in a "last one wins" manner.
- All options and associated option arguments must precede any
operands on the command line. For example, if you want to run the
cp utility with the -R option, you may enter:
cp -R dir1 dir2
but not:
cp dir1 dir2 -R
- Decimal integers are accepted when numeric values are required
in operands and option arguments, unless otherwise specified. Some
utilities may support 0octal and
0xhex numbers as well without being
documented as doing so. For this reason, don't precede decimal
numbers with leading zeros.
- Integer numerical operands and option arguments must be in the
range 0 to 2147483647 unless otherwise specified. If negative
numbers are accepted, the acceptable range is -2147483647 to
2147483647.
- The argument -- ("dash dash") may be placed on the command
line as a delimiter indicating the end of options and the start of
operands. This is particularly useful when the operands themselves
might start with a dash. For example, to remove a file named "-t",
you would use:
rm -- -t
Utilities that don't accept any options also accept
and discard a -- before their operands, unless otherwise
indicated.
- Most utilities that accept filenames as operands (and sometimes
as option arguments) accept the filename "-" to mean
standard input, or, when unambiguous from its context, standard output.