For this case I recommend sed
, this is powerful for substitution and has a short syntax.
Solution sed
:
echo This++++this+++is+not++done | sed -En 's/\\++/ /gp'
Result:
This this is not done
For awk
:
You must use the gsub
function for global line substitution (more than one substitution).
The syntax:
gsub(regexp, replacement [, target])
.
If the third parameter is ommited then $0
is the target.
Target must a variable or array element. gsub works in target, overwritten target with the replacement.
Solution awk:
echo This++++this+++is+not++done | awk 'gsub(/\\++/," ")
Result:
This this is not done