用于计算下一个ASCII字符的Linux命令或Bash语法

7 linux bash perl awk

我有一台Linux机器(Red Hat Linux 5.1),我需要将以下任务添加到我的Bash脚本中.

哪个Linux命令或Bash语法将计算下一个ASCII字符?

备注 - 命令语法也可以是AWK/Perl,但此语法必须在我的Bash脚本中.

例:

 input                  results

 a    --> the next is   b
 c    --> the next is   d
 A    --> the next is   B
Run Code Online (Sandbox Code Playgroud)

Tim*_*Tim 8

使用translate(tr):

echo "aA mM yY" | tr "a-yA-Y" "b-zB-Z"
Run Code Online (Sandbox Code Playgroud)

它打印:

bB nN zZ


TLP*_*TLP 4

Perl 的++运算符在一定程度上也处理字符串:

perl -nle 'print ++$_'
Run Code Online (Sandbox Code Playgroud)

-lautochomp 选项在这里是必要的,因为examplea\n将返回1