Sometimes I have problems with opening a file using a graphical text editor — I'm using geany
. The file can be read by vim
without a problem. I checked the file, and there wasn't anything wrong with it, except some lines. This is for example .bash_history
file:
776 reboot
777 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^ @^@^@^@^@^@^@geany /etc/fstab
....
....
823 reboot
824 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@exit
I don't know what ^@
is, but after removing each line that has it, the file can be read again in geany
. Maybe the reboot action has to do something with it? But I have other reboot
entries in the file and the ^@
characters appear only in two or three places.
This is only an example file, I saw the characters in some other files, one thing seems to be the same — it concerns only big files, those that have many lines.
Does anyone know what ^@
means, where it came from and why vim
has no problems with reading the file whereas geany
can't read it at all?
Best Answer
When ever you have stray characters in a file you can enlist the assistance of the tools
od
orhexdump
.Examples
First we'll show what octal dump (
od
) shows when we tell it to dump the contents of filea.txt
in a hexidecimal format (-x
).od
We can use
hexdump
to do something similar, showing the data in hexidecimal format, however it will also show the value as an ASCII character if possible.hexdump
Looking at the above output you'll notice several sequences of
00 00 00
. These are those ^@ characters you were asking about originally.Incidentally the character
00
is the null character.