Linux上shell脚本,字符串转ASCII码

  在shell脚本里,将字符串转ASCII码的方法:

[keysystem@localhost ~]$ printf "%d" "'A"
65
[keysystem@localhost ~]$ printf "%d" "'0"
48

  在shell脚本里,将字符串转10进制转16进制的方法:

[keysystem@localhost ~]$ printf "%x" 10
a

 

 

  printf更多用法参考:http://man.linuxde.net/printf

posted @ 2017-12-08 09:16  alsodzy  阅读(9209)  评论(0编辑  收藏  举报