How do you echo a 4-digit Unicode character in Bash?

后端 未结 18 2059
醉梦人生
醉梦人生 2020-11-29 14:38

I\'d like to add the Unicode skull and crossbones to my shell prompt (specifically the \'SKULL AND CROSSBONES\' (U+2620)), but I can\'t figure out the magic incantation to m

18条回答
  •  醉话见心
    2020-11-29 15:11

    Quick one-liner to convert UTF-8 characters into their 3-byte format:

    var="$(echo -n '☠' | od -An -tx1)"; printf '\\x%s' ${var^^}; echo
    

提交回复
热议问题