Convert decimal to hexadecimal in UNIX shell script

后端 未结 11 785
孤城傲影
孤城傲影 2020-11-29 19:08

In a UNIX shell script, what can I use to convert decimal numbers into hexadecimal? I thought od would do the trick, but it\'s not realizing I\'m feeding it ASCII represent

11条回答
  •  有刺的猬
    2020-11-29 19:12

    echo "obase=16; 34" | bc
    

    If you want to filter a whole file of integers, one per line:

    ( echo "obase=16" ; cat file_of_integers ) | bc
    

提交回复
热议问题