0

when I less a file, it looks like this.

^@00002201-271f-43b9-81a7-000b0a31abe5
^@00004695-2281-44df-b18d-bd68b63fced4
^@00009273-3a0f-4c2e-b708-805e02147f55
^@0000a0e6-3889-43f2-9635-63e114c38f29
^@0000a386-cf2f-4459-bd63-e83fb144013c

The problem is ^@. When cat this file, that character is not seen.

What is that character? And How can I trim that (in C or awk whatever)?

1 Answer 1

2

^@ represents the NULL (0x00) byte. (The ^x is shorthand for Ctrlx, which on terminals would clear the two highest bits of the pressed key; so while A is 0x41 [0100'0001], Ctrl+A would input 0x01 [0000'0001], and so on.)

To remove it, pipe through sed 's/^\x00//', or sed 's/\x00//g' if it occurs in other places.

However, NULL is usually simply ignored. If the first character gets trimmed, then you probably have something more than that in the file. Consider looking at its hexdump, e.g. with xxd, hexdump -C, cat -v, or sed -n l.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .