Date: 7 Dec 2017 01:26:12 -0000 From: "John Levine" <johnl@iecc.com> To: freebsd-questions@freebsd.org Cc: zarniwhoop@ntlworld.com Subject: Re: grep problem Message-ID: <20171207012612.41249.qmail@ary.lan> In-Reply-To: <20171207010801.GA10604@milliways.localdomain>
next in thread | previous in thread | raw e-mail | index | archive | help
In article <20171207010801.GA10604@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20171207012612.41249.qmail>