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

后端 未结 18 1993
醉梦人生
醉梦人生 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 14:56

    If you don't mind a Perl one-liner:

    $ perl -CS -E 'say "\x{2620}"'
    ☠
    

    -CS enables UTF-8 decoding on input and UTF-8 encoding on output. -E evaluates the next argument as Perl, with modern features like say enabled. If you don't want a newline at the end, use print instead of say.

提交回复
热议问题