Post tagged: sed

Using plus in regex with sed

I was trying to remove trailing whitespace from some files with sed:

sed -i 's/[[:space:]]+$//g'

But this left the file unmodified! For some reason, the pattern wasn't matching. I took a look at the man page and noticed the -E flag:

use extended regular expressions in …