Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Dec 2017 00:55:42 +0000
From:      RW <rwmaillists@googlemail.com>
To:        freebsd-questions@freebsd.org
Subject:   grep problem
Message-ID:  <20171207005542.43a7f55f@gumby.homeunix.com>

next in thread | raw e-mail | index | archive | help

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]...
Try `grep --help' for more information.

$ echo 'a-b' | grep  '\-b'
a-b




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20171207005542.43a7f55f>