整数ASCII值字符在BASH用printf [英] Integer ASCII value to character in BASH using printf

查看:95
本文介绍了整数ASCII值字符在BASH用printf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人品价值的作品:

$ printf "%d\n" \'A
65
$

我有两个问题,第一个是最重要的:

I have two questions, the first one is most important:


  • 如何采取65和把它变成一个?

  • \\'A ASCII字符用printf转换为它的价值。是语法的具体的到的的printf 的或者是其他任何地方使用的BASH? (这种小串是很难谷歌的。)

  • How do I take 65 and turn it into A?
  • \'A converts an ASCII character to its value using printf. Is the syntax specific to printf or is it used anywhere else in BASH? (Such small strings are hard to Google for.)

推荐答案

一号线

printf "\x$(printf %x 65)"

两行

set $(printf %x 65)
printf "\x$1"

下面是一个,如果你不介意使用 AWK

Here is one if you do not mind using awk

awk 'BEGIN{printf "%c", 65}'

这篇关于整数ASCII值字符在BASH用printf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆