Tuesday, November 6, 2012

How to grep for null character

I had the exquisite pleasure of having to recover some text files that I accidentally deleted. From grepping for expected text fragments in the storage device and dumping the context, I got a lot of non-printable content, consisting mainly of the null character. To simplify the job of visually salvaging the text files, I had to remove sections that are not printable. One way to do this is to drop parts that has the null character. bash apparently doesn't let you enter the null character, so what to do?

grep -P '\000'

1 comment: