Awk - how to specify a field separator as a binary value 0x1

Is it possible to specify a separator field FSin binary format for awk?

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

If it were a symbol '1', it would look like this:

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

Or in a script:

#!/bin/awk -f

BEGIN { FS = "1" }

/FIELD/ { print $1 }

How can I indicate FS/Fhow 0x1.

+3
source share
1 answer
#!/bin/awk -f

BEGIN { FS = "\x01" }

/FIELD/ { print $1 }

See http://www.gnu.org/manual/gawk/html_node/Escape-Sequences.html .

+5
source

Source: https://habr.com/ru/post/1723411/


All Articles