Reputation: 11740
I'm trying to use grep on Windows to search all files in the current directory for the word foo
followed by any white space.
I tried:
grep foo\s *
But it doesn't work. It matches foos
though. I was under the impression that \s
should match a white space. Indeed it does in other regular expression testers.
I also tried grep foo\\s *
grep "foo\s" *
and countless other attempts.
What am I missing?
I'm using GNU grep 2.5.4 on Windows 10 in cmd.exe
Upvotes: 2
Views: 160
Reputation: 11547
It seems there is a bug with the handling of \s in grep up to version 2.5 grep regex whitespace behavior
You have several alternatives to it
grep "foo[ \t] *
grep "foo[[:space:]]" *
or if you dont care about tabulation
grep "foo " *
Upvotes: 1