I need to replace all occurrences of the control character CTRL+A (SOH/ascii 1) in a text file in linux, how can this be achieved in SED?
This can be done through
cat with the
--show-nonprinting options and piping this into
If the control character the start of heading (SOH) character (CTRL+A / ASCII 1), and we want to replace it with a tab, we would do the following:
cat -v file | sed 's/\^A/\t/g' > out
cat -v would replace the SOH character with ^A, which would then be matched and replaced in