Sed's irregularities with regular expressions

Sed, Linux

When using regular expressions in sed, be aware that some metacharactes need to be escaped.

For example sed -e 's/-[0-9]+//' should probably be written as sed -e 's/-[0-9]\+//' if you want to replace 1 or more digits.

The first regex will look for a digit followed by a plus sign. This also applies to parenthesises.

Comments powered by Disqus

Copyright 2010. All Rights Reserved.