[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tue, 23 Sep 2003 09:31:10 +0200
On Mon, Sep 22, 2003 at 02:21:41PM -0400, Gerald S Stoller wrote:
> FreeBSD 4.3-RELEASE FreeBSD 4.3-RELEASE #0: Sat Apr 21 10:54:49 GMT 2001
> address@hidden:/usr/src/sys/compile/GENERIC i386
unfortunately, I cannot a FreeBSD system at hand, so I cannot tell which
version of GNU grep this implies but I'll suppose you have 2.5 or 2.5.1,
similarily to my system:
$ grep --version
grep (GNU grep) 2.5.1
> the grep -w line output
The man page says exactly that -w means that the match may not be preceded
nor followed by a word constituent character. The behaviour follows
> 0-$ echo "fgh( hkjh\nfgh(hkjh\nfgh((hkjh" | grep -w "fgh("
> fgh( hkjh
Of course, typical usage of -w is that the pattern is a word and you
search exactly for that word. If the pattern is not a word, things
look a bit strange, but they are correctly documented.
I think that when you need some finer things with "words", it's better
to make use of \<, \>, \b and \B.
> In addition, in the grep command's pattern string, the man page
> (in FreeBSD ) says that the characters '?', '+', and '*' are
> naturally metacharacters. However, in practice I found that '+'
> must have a preceding backlash to be viewed as a metacharacter.
The manpage states clearly that it documents extended regular
expressions, the differences for "basic" regular expressions
are listed below.
> In egrep use, though, I find how it views "+" & "\+" to be
BTW: according to POSIX, "egrep" is obsolete; perhaps you could
acquire a habit of using "grep -E" instead.
Hope this helps,
- grep, Gerald S Stoller, 2003/09/22
- Re: grep,
Stepan Kasal <=