0

I have a string (4_HEATING_1 = (2)) AND (4_DRYER_1 > (7)) and I would like to change the numbers enclosed in brackets to make the string look like (4_HEATING_1 = Step (2)) AND (4_DRYER_1 > Step (7)).

Note the = might be <, >, <>, <= or >= and that the number in the bracket can be any number.

I have tried

sed -e "s/\(.*\)\(([0-9])\)/\1 Step \2/g"

but this only produces (4_HEATING_1 = (2)) AND (4_DRYER_1 > Step (7)).

Any help appreciated

1 Answer 1

1
$ foo='(4_HEATING_1 = (2)) AND (4_DRYER_1 > (7))'
$ printf "%s\n" "$foo" | sed 's/([0-9][0-9]*)/Step &/g'
(4_HEATING_1 = Step (2)) AND (4_DRYER_1 > Step (7))
2
  • That works great, thank you so much for the quick response, been trying for ages
    – UkTerry
    Commented Feb 6, 2020 at 20:48
  • Pleased to have been of service. Since this answered your question, please click the grey check to the left to mark it as answered so that people can see the problem has been solved. Welcome to U&L!
    – DopeGhoti
    Commented Feb 6, 2020 at 20:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .