bash ascii to hex

前端 未结 5 2061
野的像风
野的像风 2020-12-28 16:45

was wondering if anyone could help me with converting ascii to hex in bash. Example code:

#!/bin/bash 
STR = \"hello\"
#Convert to hex
HEXVAL = $STR #(in hex         


        
5条回答
  •  萌比男神i
    2020-12-28 16:54

    You have several options

    $ printf hello | xxd
    0000000: 6865 6c6c 6f                             hello
    

    See also: Ascii/Hex convert in bash

提交回复
热议问题