Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Instead of > output.txt why not try something along the lines of echo Start > output.txt. Hopefully, grep won't think it's a binary file. Commented Oct 15, 2014 at 13:46
  • 2
    Best would be to use tee -a. See there for details (tee -a is the equivalent of shells using >>). Commented Oct 15, 2014 at 15:08
  • 1
    @StéphaneChazelas, I think that's the best answer in this thread Commented Oct 15, 2014 at 16:56
  • 1
    If you truncate the file while open, the next write (by | tee) will refill it with zeros and the write will occur at the previous offset. grep treats an occurrence of 0 within the first buffer read (32kiB) as a binary file by default. Commented Oct 15, 2014 at 19:48