Print the next ASCII character

Hi,
In my file, for few field I have to print the next ASCII character for every character.

In the below file, I have to do for the 2,3 and 5th fields.

Input File
========
1|abc|def|5|ghi
2|jkl|mno|6|pqr
 
Expected
 
Ouput file
=======
1|bcd|efg|5|hij
2|klm|nop|6|qrs
perl -e 'while(<>){s/([a-y])/chr(ord($1) +1 )/eg;print}' tmp.dat

Note that the character range [a-y] should be extended/pruned to fit your spec

A unix way with "tr": Assumes columns 1 and 4 are always numbers and columns 2,3 and 5 are always lower-case letters.

cat input.txt | tr '[abcdefghijklmnopqrstuvwxyz]' '[bcdefghijklmnopqrstuvwxyza]' >output.txt
1 Like