filter - How to escape minus in regular expression with sed? -
i need free string unwanted characters. in example want filter +
's , -
's b , write result c. if b +fdd-dfdf+
, c should +-+
.
read b c=$(echo $b | sed 's/[^(\+|\-)]//g')
but when run script, console says:
sed: -e expression #1, char 15: invalid range end
the reason \-
in regular expression. how can solve problem , say, want filter -
's?
are looking this?
kent$ echo 'a + b + c - d - e'|sed 's/[^-+]//g' ++--
Comments
Post a Comment