rainbowbird
6/20/2018 - 3:21 PM

From https://blog.fpmurphy.com/2010/12/shell-script-print-hexadecimal-representation-of-string.html

str="Hi there Vi Castillo!"

for (( i=0; i < ${#str}; i++ )) do 
    c=${str:$i:1} 
    if [[ $c == ' ' ]] then 
        printf "[%s] 0x%X\n" " " \'\ \'
    else
        printf "[%s] 0x%X\n" "$c" \'$c\' 
    fi 
done