I have some database dumps from a Windows system on my box. They are text files. I'm using cygwin to grep through them. These appear to be plain text files; I open them with text editors such as notepad and wordpad and they look legible. However, when I run grep on them, it will say binary file foo.txt matches
.
I have noticed that the files contain some ascii NUL
characters, which I believe are artifacts from the database dump.
So what makes grep consider these files to be binary? The NUL
character? Is there a flag on the filesystem? What do I need to change to get grep to show me the line matches?
Best Answer
If there is a
NUL
character anywhere in the file, grep will consider it as a binary file.There might a workaround like this
cat file | tr -d '\000' | yourgrep
to eliminate all null first, and then to search through file.