I want to replace strings which contain tilde character of varying lengths with strings of spaces. For example, if a string contains 5 tilde characters: ~~~~~, then I want to replace it with 5 spaces.
My current sed command:
sed -e '/\\begin{alltt}/,/\\end{alltt}/s/~\+/ /' test.tex
I can check for one or more tilde characters, but don't know how to retrieve the length to insert the spaces
s/~/ /gnot an option? Or do you need to replace only the first sequence of~s on a line?