print hex strings in readable ascii format

  • Follow


Hi,

I wonder if there is some neat way to convert a hex string to ascii
before printing it. E.g I have a file that contains following line
with hex data:

68656c6c6f00

I want to print it using printf with the result:

'hello'

Is this possible in gawk?

/S

0
Reply di98mase (15) 8/16/2007 12:56:47 PM

In article <1187269007.050724.132540@r34g2000hsd.googlegroups.com>,
di98mase  <di98mase@hotmail.com> wrote:
>Hi,
>
>I wonder if there is some neat way to convert a hex string to ascii
>before printing it. E.g I have a file that contains following line
>with hex data:
>
>68656c6c6f00
>
>I want to print it using printf with the result:
>
>'hello'
>
>Is this possible in gawk?

#!gawk
{
for (i=1; i<length($0); i+=2)
    printf("%c",strtonum("0x"substr($0,i,2)));print ""
}

0
Reply gazelle 8/16/2007 1:28:26 PM


1 Replies
335 Views

(page loaded in 0.07 seconds)

Similiar Articles:













7/28/2012 3:46:25 AM


Reply: