I have a text file containing unwanted null characters (ASCII NUL, \0). When I try to view it in vi I see ^@ symbols, interleaved in normal text. How can I:
-
Identify which lines in the file contain null characters? I have tried grepping for
\0and\x0, but this did not work. -
Remove the null characters? Running
stringson the file cleaned it up, but I’m just wondering if this is the best way?
I’d use
tr:If you are wondering if input redirection in the middle of the command arguments works, it does. Most shells will recognize and deal with I/O redirection (
<,>, …) anywhere in the command line, actually.