grep problem

RW rwmaillists at googlemail.com
Thu Dec 7 01:19:54 UTC 2017


On Thu, 7 Dec 2017 00:55:42 +0000
RW wrote:

> Can anyone explain why '-' needs escaping in the following. What
> special meaning does it have outside of []? 
> 
> $ echo 'a-b' | grep  'a-b'
> a-b
> 
> $ echo 'a-b' | grep  '-b'
> Usage: grep [OPTION]... PATTERN [FILE]...


Never mind, the shell handles the quotes, so grep sees -b as an option
rather than a pattern.


More information about the freebsd-questions mailing list