tags:

views:

78

answers:

1

Hi all,

I was working on the Linux box A and I run this:

grep '^\S*\s-' access_log

That displayed some lines, as expected.

Then I moved to the machine B and I launched exactly the same command. But this time it didn't work.
I had to launch this in order to get done what I needed:

grep '^[^ ]* -' access_log  

Before succeeding, I tried all of these but with no luck:

grep '^\S* -' access_log  
grep '^\S*\s-' access_log      
grep -e '^\S* -' access_log   
grep -E '^\S* ' access_log    

It looks like machine B doesn't understand the metacharacters \S and \s.

Both of the boxes were running: grep 2.5.1 and bash 3.2.25

How is that possible?

Cheers, Dan

+1  A: 

Judging from the grep man page. It seems that if you can use things like \s you are using Perl regular expressions. Which are used when the -P option is passed to grep. So it may be that that option is set automatically on machine A and not on machine B. The reason for that may be some alias, or the option is set in GREP_OPTIONS.

Peter van der Heijden