Replacing [0-9] with [A-J] not working with sed
In substitution, only the match (left-hand side) is a regular expression. The replacement is more or less just a literal string (with some backslash expansion) – it's not a regex.
You want transliteration, not substitution, so replace s
with y
:
echo 34031445 | sed 'y/0123456789/ABCDEFGHIJ/'
sed can't use ranges in y
, but Perl can:
echo 34031445 | perl -pe 'y/0-9/A-J/'
Or just use tr
:
echo 34031445 | tr 0-9 A-J