Strange grep behavior

From: Helge Preuss (spam.preuss_at_fhi-berlin.mpg.de)
Date: 11/10/03


Date: Mon, 10 Nov 2003 16:02:31 +0100

Hi,
a colleague of mine complained to me that grep does not print lines
matching the search expression in some of his files, giving the message
"binary file foo.txt matches". Now his files are just plain old text
files. What is even stranger, if he renames that file, grep prints the
matching lines.
Now I was not able to reproduce this behavior, but I found a different
unexpected behavior: grepping for a string in a binary file, which i
know it exists, two times out of three (different strings) it does not
find the search string. The third time, it just prints the string. No
line number, no mention of a binary file eiteher.
So my questions: Is this behavior known, maybe even documented? More
generally, how does grep determine whether a file is a binary?
The OS in case is Tru64 5.1a.
TIA
Helge

-- 
hint: my first name is not "spam"!


Relevant Pages

  • Re: Strange grep behavior
    ... > lines matching the search expression in some of his files, ... grep prints the matching lines. ... > strings) it does not find the search string. ...
    (comp.unix.tru64)
  • Re: File handling
    ... > I have a problem on retriving a content of a binary file I wrote into. ... Now you try to write a structure, containing a pointer to a string. ...
    (comp.lang.c)
  • Re: Interesting problem: serializing in with MFC CArchive, reading out using C# BinaryReader
    ... I solved it by looking into the MFC ... public string ReadCString() ... >> I am able to open the binary file and read out the individual ... >> old string termination issues, but I've checked the byte representing ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Speed of Applications in VBA vs VB
    ... I dont think there are any cr lf in the binary file but I'm learning a lot ... Dim filebuffer As String ... I will try the streamreader. ... functionality around the VBA engine that is not available in VBA (creating ...
    (microsoft.public.excel.programming)
  • Re: Problem in writing structure to Binary file in C lang
    ... reading those data from binary file and display it in C language. ... How should the program know the size of the string without actually ... but not the string pointed to by the structure, it also writes a binary pointer to ...
    (comp.lang.c.moderated)