Parameter expansion of variable containing control characters
2
votes
2
answers
355
views
I'm looking to replace the group separator control character, which is printed by the terminal as "^]" and has got octal code of: 035, with a space.
This can simply be done using tr, like so:
echo $line | tr '\035' ' '
.
However, I don't (can't) use an external command in my bash script, so am instead looking to use parameter expansion to replace the control characters with spaces.
What is the correct syntax to match the control character, the below options don't work:
${line//'\035'/' '}
${line//'\0035'/' '}
${line//\035/' '}
${line//$'\035'/' '}
Or is there another way to replace the character without using external commands such as tr and sed?
Asked by Maikol
(164 rep)
Jan 4, 2024, 09:19 PM
Last activity: Jan 5, 2024, 09:42 AM
Last activity: Jan 5, 2024, 09:42 AM