Skip to content

Instantly share code, notes, and snippets.

@palday
Created January 29, 2013 17:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save palday/4665843 to your computer and use it in GitHub Desktop.
Save palday/4665843 to your computer and use it in GitHub Desktop.
A few ways to find and get rid of NULL bites in documents.
tr < file-with-nulls -d '\000' > file-without-nulls
sed 's/\x0//g' file-with-nulls > file-without-nulls
sed 's/\x0/ /g' file-with-nulls > file-without-nulls
grep -P '\000' < file-with-nulls >file-without-nulls
awk '/\000/ { print }'
perl -ne 'print if m/\000/'
# python
f = open('file-with-nulls')
for l in f.readlines():
print l.replace("\0", '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment