Wednesday, February 24, 2016

Removing junk characters from file - NUL (^@) characters

The NUL character  in file shows up on windows in Notepad++ as shown below-


The NUL character shows in ^@ on Unix/Linux as shown below -


To detect NUL characters in a large file -

  • Unix/Linux: Use grep command in Perl mode and give hex representation of the character: grep -P '\0' Filename
  • Windows Text Editor: find all matches by 
    Notepad++
Now comes the final part how to remove these characters so that the file can be processed successfully -
cat OriginalFile | tr -d '\0' > TransformedFile



If you like this post please hit the like button!!

1 comment: