You are not logged in.
Pages: 1
I have quite a few scripts in which I use grep with the combination \s* to represent any number of whitespace characters.
As of the recent update to 2.15 these scripts have all stopped working. However [\s]* seems to work:
$ echo ' foo' | grep '\s*foo'
$ echo ' foo' | grep '[\s]*foo'
fooIs the first syntax wrong, and if so, why? Have I been grepping wrong for years? Should I change all my scripts, or is this a bug with grep 2.15?
Last edited by frabjous (2013-11-01 15:41:27)
Offline
There's https://bugs.archlinux.org/task/37556 , so maybe some things did change in grep 2.15.
Edit: egrep works:
$ echo ' foo' | egrep '\s*foo'
fooLast edited by karol (2013-11-01 15:56:56)
Offline
Yeah, I'm pretty sure this is a bug. Bleeding edge and all that. https://www.gnu.org/software/grep/manual/grep.html makes no mention of such a removal. [[:space:]] still works too.
I didn't know regular grep did such things; I never bothered to learn the difference and so always use egrep when doing anything more complex than ^ and $ anchors.
Offline
Thanks for the suggestions. I'm a bit hesitant to switch to egrep, since I'm not that familiar with what the differences are, and of course my actual regex's are much more complicated than the toy example above.
I do think it is a bug. I'd file a bug report, but there doesn't seem to be a way to do so unless you're on the dev mailing list, which is rather annoying.
Offline
--------------------------------------
Grep searches the named input FILEs (or standard input if no files are
named, or the file name - is given) for lines containing a match to the
given PATTERN. By default, grep prints the matching lines.
In addition, two variant programs egrep and fgrep are available. Egrep
is the same as grep -E. Fgrep is the same as grep -F.
-E, --extended-regexp
Interpret PATTERN as an extended regular expression (see below).
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by new-
lines, any of which is to be matched.
*apologies
Last edited by jasonwryan (2014-09-18 01:28:32)
Offline
@nuf0xx Please use code tags when pasting to the boards https://wiki.archlinux.org/index.php/Fo … s_and_Code
And there is no need to paste that ascii art thing, it adds nothing to the thread.
Offline
Please note this thread is almost a year old. The bug I reported on no longer exists in the current version of grep, and so the thread is now irrelevant. nuf0xx's copy and paste job would not have been relevant anyway.
Offline
Pages: 1