Why does this sed command not match whitespace?

This bash script is supposed to remove leading whitespace from grep results:

grep --color=always $@ | sed -r -e's/:[[:space:]]*/:/'

But it doesn't match the whitespace. If I change the substitution text to "-", that shows up in the output, but it still never removes the whitespace. I've tried it without the "*", escaping the "*", with "+", etc, but nothing works. Does anyone know why not?

(I'm using sed version 4.2.1 on Ubuntu 12.04.)

Thanks all, this is my modified script, which shows grep color and also trims leading blanks:

grep --color=always $@ | sed -r -e's/[[:space:]]+//'


You need to remove the --color option for this to work. The color codes confuse sed:

grep  $@ | sed -r -e's/:[[:space:]]*/:/'

Need Your Help

iOS Facebook API fetch data from timeline using GRAPH API

ios facebook facebook-graph-api

We have a facebook account. That account 'Liked' 3 open facebook pages. When you login to that facebook account from your browser you can ofcourse see all the posts from those 3 pages on your news ...

fonts in Chrome not showing

html css google-chrome

I am having a little issue with a font in Chrome. I think it's the way I'm specifying it. I have: