tags:

views:

294

answers:

1

Is it possible to specify the separator field FS in binary for awk?

I have data file with ascii data fields but separated by binary delimiter 0x1.

If it was character '1' it would look like this:

awk -F1 '/FIELD/ { print $1 }'

Or in script:

#!/bin/awk -f

BEGIN { FS = "1" }

/FIELD/ { print $1 }

How can I specify FS/F to be 0x1.

+2  A: 
#!/bin/awk -f

BEGIN { FS = "\x01" }

/FIELD/ { print $1 }

See http://www.gnu.org/manual/gawk/html%5Fnode/Escape-Sequences.html.

JSBangs
Hm, right ... I tried that but it did not work form me originally ... until I remembered that my separator is binary 0x2 .... I thought I have problem with specifying binary separator ... thanks a lot
stefanB