Identifying and removing null characters in UNIX

Posted by fahdshariff on Stack Overflow See other posts from Stack Overflow or by fahdshariff
Published on 2010-03-07T23:12:33Z Indexed on 2010/03/08 7:21 UTC
Read the original article Hit count: 297

I have a text file containing unwanted null characters. When I try to view it in I see ^@ symbols, interleaved in normal text. How can I:

a) Identify which lines in the file contains null characters? I have tried grepping for \0 and \x0, but this did not work.

b) Remove the null characters? Running strings on the file cleaned it up, but I'm just wondering if this is the best way?

Thanks

© Stack Overflow or respective owner

Related posts about unix

Related posts about shell-scripting