Conversion hex string into ascii in bash command line

前端 未结 7 1479
孤独总比滥情好
孤独总比滥情好 2020-12-12 23:43

I have a lot of this kind of string and I want to find a command to convert it in ascii, I tried with echo -e and od, but it did not work.

7条回答
  •  离开以前
    2020-12-13 00:08

    Make a script like this:

    #!/bin/bash
    
    echo $((0x$1)).$((0x$2)).$((0x$3)).$((0x$4))
    

    Example:

    sh converthextoip.sh c0 a8 00 0b

    Result:

    192.168.0.11

提交回复
热议问题