Arguments That Look Like Options

You may have encountered a situation in which you wanted to specify an argument that started with a hyphen, and your command complained about the improper options that were being used. For example, if grep(1) were used to search a source program for the string --help, you might experience the following under FreeBSD:

$ grep --help tempnam.c
grep: illegal option -- -
usage: grep [-[AB] <num>] [-CEFGLVXHPRSZabchilnqsvwxy]
       [-e <expr>] [-f file] [files ...]
$

The problem with this grep(1) command is that the command was confused about how to treat the text --help. The following technique shows how to avoid this little problem:

$ grep -- --help tempnam.c
$

The example shows that grep(1) understood the -- (double hyphen) on the command line to indicate that there were no further options. This permitted grep(1) to understand that --help was the text being searched for in the file tempnam.c.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.67.251