tags:

views:

47

answers:

1

Hello, may be this is newbie question, but I must ask it!
In general I'm understand regular expressions, but I don't understand, why this one:

^.{8}[[:blank:]]{2}

works on this line:

prelink: /lib/libkeyutils-1.2.so: at least one of file's dependencies has changed since prelinking

in this grep command:

echo "prelink: /lib/libkeyutils-1.2.so: at least one of file's dependencies has changed since prelinking" | grep -v '^.\{8\}[[:blank:]]\{2\}'

where:

The                says "beggining of line"  
The .{8}           says "any eight characters"  
The [[:blank:]]{2} says "any two space characters"  

So ^.{8} match "prelink:", when [[:blank:]]{2} need matching "  " (two spaces), but we have only " " (one space)... So why this work at all, and if this work why this one:

^.{8}[[:blank:]]{1} 

doesn't work?

Thank you for ahead.

+8  A: 

You're using grep with the -v option which causes it to print lines which don't match. Remove the -v and it will work as you expect.

grep --help
...
   -v, --invert-match        select non-matching lines
...
Mark Byers
Thank you, I was sure that -v is: "using regular expressions"
rodnower
@rodnower: No, it's the "grep" part that means that. :D
Alan Moore