grep problem
John Levine
johnl at iecc.com
Thu Dec 7 01:26:36 UTC 2017
In article <20171207010801.GA10604 at milliways.localdomain> you write:
>> $ echo 'a-b' | grep '-b'
>> Usage: grep [OPTION]... PATTERN [FILE]...
>> Try `grep --help' for more information.
>>
>> $ echo 'a-b' | grep '\-b'
>> a-b
>In gnu grep, '-' indicates it should read from STDIN, I assume that
>FreeBSD's grep is the same.
Close, but not quite. A quick peek at the grep man page (you did look
at the man page, didn't you?) reveals that -b is a flag telling what
byte offset to start at. A more normal way to prevent your pattern
from being treated as a flag is to tell it that it's a pattern:
$ echo a-b | grep -e -b
R's,
John
More information about the freebsd-questions
mailing list