2012年1月20日星期五

file hole in Linux files

Yesterday, I posted a question on http://unix.stackexchange.com/, to get method how to delete a kind of special string ˆ@ˆ@ˆ@ˆ@ˆ@ˆ@ in my files. Those problematic files were those have ever been written by different processes. In fact, I guess this special string was coming with the multiple writing.


Finally, I got very good answers from that forum. Thanks to all those helpers. I copy/paste the answer here.


############################################################

These ^@ are null characters, which have an ASCII code of 0.
You can delete them using:
tr -d '\000' < myfile > myfile.out
or:
sed 's/\x0//g' < myfile > myfile.out
It's possible that this is a file holeI 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.

没有评论:

发表评论