Hex to Binary conversion in bash

后端 未结 4 1087
说谎
说谎 2021-02-20 14:08

I\'m trying to convert a series of bytes from hex to bin using bash. but I keep getting (seemingly random) \"(standard_in) 1: syntax error\" replies from the following code:

4条回答
  •  名媛妹妹
    2021-02-20 14:25

    Try this:

    for j in c4 97 91 8c 85 87 c4 90 8c 8d 9a 83 81
    do
        BIN=$(echo "obase=2; ibase=16; ${j^^}" | bc )
        echo $BIN
    done
    

提交回复
热议问题