change each letter of a string

Is there a way to change each letter of a string to the next one in the alphabet, so that a becomes b and f becomes g, and digits become one unit bigger - 4 becomes 5 and 9 becomes 0.

I want to change strings like ben123 to cfo234.

I'll assume that the edge case you want 9 to go to 0 rather than 10 or ":"

 perl -e ' $string="ben123";$string=~s/9/0/g;$string=~s/([^9])/chr(ord($1) +1)/eg;print "$string\n";

Try with tr command.

tr 'abc123' bcd234' < inutfile #add remaining alphabets and numbers 

Using hexdump:

hexdump -e '/1 "(%u+1)%%256\n"' file | bc | awk '{printf("%c", $0)}'

Using only POSIX tools and features:

od -An -tu1 file | tr -c '[0123456789]' '[\n*]' | sed '/..*/s//(&+1)%256/' | bc | awk '{printf("%c", $0)}'

Note: Some hexdump implementations have (or used to have) problems with the %% sequence. Instead of printing a literal percentage symbol as expected, they complain about a bad conversion character.

Regards,
Alister

You can do it all in one tr, no need to od | tr | awk | sed | this | that | whatever. Just match your output set to what you want.

input: a-z
output b-za

input: A-Z
output: B-ZA

input: 0-9
output: 1-90

$ echo ben123 | tr '[a-zA-Z0-9]' '[b-zaB-ZA1-90]'
cfo234
$

Thank you, I was looking for something like the last one.