yuripv at gmx.com
Thu Dec 7 01:20:18 UTC 2017
On Thu, Dec 7, 2017 at 00:55:42AM +0000, RW via freebsd-questions wrote:
> Can anyone explain why '-' needs escaping in the following. What
> special meaning does it have outside of ?
> $ echo 'a-b' | grep 'a-b'
> $ echo 'a-b' | grep '-b'
> Usage: grep [OPTION]... PATTERN [FILE]...
> Try `grep --help' for more information.
> $ echo 'a-b' | grep '\-b'
Looks like it's treated as option -b even inside the single quotes, you
could use '--' to mark the end of options, i.e.:
$ echo 'a-b' | grep -- -b
More information about the freebsd-questions