I'm trying to use tr
in bash to replace only the final character of a match. The string will have a substring with 5 digits followed by a dash, but I want to replace that dash with a slash.
I want to use something like this:
echo "xyzvb12345-Ab-C5678-dEf" | tr "#####-" "#####/"
To get an output like this:
xyzvb12345/Ab-C5678-dEf
Is there a way to do this with tr
? Or maybe sed
?
EDIT: This is not a duplicate of the many tickets out there that merely find and replace text. Please read carefully before marking as a duplicate.