I’m writing a sed script part of which requires replacing characters from a certain subset with the hexadecimal values of their ASCII codes. I did some research and I could not find anything, so I’m starting to think that sed does not have a feature that would let me do that. If there are any sed gurus here, could you please enlighten me?
P.S.: solutions like sed -e "s/A/41/g" -e "s/B/42/g"... etc won’t do.
while IFS= read -r -n1 c; do printf ‘%x’ “‘$c”; done < infile > outfileNo,
sed‘s ‘s’ command can only convert characters to their lower/upper case counterparts, it doesn’t have a facility to replace them with their equivalent ascii code. There is the ‘y’ command for transliteration but that requires a 1-for-1 mapping in length, so that won’t work.Without seeing your code, my best recommendation is a move to
awk