Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a simple problem:

In my file, the are lines containing the string ˆ@ˆ@ˆ@ˆ@ˆ@ˆ@. I just want to delete all lines with this string, using for example the sed or grep commands.

And I would like to know why there is such string occurred in my file. What is it meaning for in Linux/Unix world?

share|improve this question
Just to point it out: the ˆ caret is different from the ^ caret sign. – user13742 Jan 19 '12 at 14:15
in my case, it should be the ˆ caret. I may have mixed them. – jianfeng.mao Jan 19 '12 at 14:38
up vote 13 down vote accepted

These ^@ are null characters, which have an ASCII code of 0.

You can delete them using:

tr -d '\000' < myfile > myfile.out


sed 's/\x0//g' < myfile > myfile.out

It's possible that this is a file hole. I have also seen this issue in the past - these null characters appeared in my logs when I was running out of disk space and processes were trying to write to them.

share|improve this answer
+1 for explaining what they are – n0pe Jan 19 '12 at 14:56
I realize my answer will not be useful if the file contains literal null characters. Your answer is a better solution. – user13742 Jan 19 '12 at 15:13
Sparse files will also output the nul character. But removing them in this way may be undesirable (adding blocks where some did not exist before. Best to check the number of blocks (ls -s) vs (ls -l) or with stat. – Arcege Jan 19 '12 at 15:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.