PKumar
PKumar

Reputation: 11128

what is ^@ character in vi?

I am seeing a lot of ^@ character in a contents of a text file on my UNIX server. I am unable to understand what does ^@ mean? and how to remove them from the file? and above all why it is generated?

If i try to see the contents of the file using cat , I am getting this:

u3210#"! utypyado

however if try to use cat -v , i am getting ^@ characters (as attached screenshot) along with some text in english. Same output is observed when i use vi with :set list command.

Any help is much appreciated , thanks very much in advance.

enter image description here

Upvotes: 17

Views: 17285

Answers (2)

benjifisher
benjifisher

Reputation: 5122

You can answer the question yourself: at least, the "what character is this" part, not the "how did it get here" part. From :help ga:

Print the ascii value of the character under the
cursor in decimal, hexadecimal and octal.  For
example, when the cursor is on a 'R':
        <R>  82,  Hex 52,  Octal 122

For more details and related commands, see the full entry.

Upvotes: 1

anubhava
anubhava

Reputation: 786289

As the comments say ^@ is actually a null byte (\x00) in your file.

If you want to get rid of all null byte instances then you can use this command in vi:

:%s/[\x0]//g

Upvotes: 17

Related Questions