[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#30326: grep not searching through a text file (thinking it binary)

From: Paul Jackson
Subject: bug#30326: grep not searching through a text file (thinking it binary)
Date: Mon, 05 Feb 2018 10:05:05 -0600

A couple of possible "solutions" to this quandary:


If one goal of the  current grep behavior is to avoid putting out
"junk" unexpectedly, then instead of rejecting input files that
have any such "junk", rather happily grep on any dang file, by
default, but then filter the output to suppress the "junk".

For many years now, I've been using my own private mutant
semi-brain damaged grep-variant that I use for searching for
text within mostly binary files that does this ... it will look for
any specified sequence of non-nul bytes  within any bucket of
bits, and when found, work forward and backward until it hits
either a newline or a non-ASCII character, and then limit it's
output to what is between those beginning and ending points. 
No non-ASCII junk will be output (except in so far as that was
part of the requested search string.)   My private mutant only
does fixed strings (grep -F equivalent), but I imagine that the
same trimming of output could be done on a real grep as well. 

Since "grep" is commonly used in shell scripts, I name my mutant
by some other name, and let "grep" continue to be whatever is
the current convention.

In short, if the goal is to not output "junk", then perhaps that is
what the current "grep" should do, rather than rejecting
from even considering everything in a file after it encounters
any "junk" character (even if it has already successfully found
and emitted some matches earlier in the file.)


Second possibility: keep one's own private copy of whatever
grep last performed as desired, in a "bin" that's on one's path
ahead of whatever "standard" and "current" grep is installed.

For many years now, I've continued to use the "ed" command
that was current back then (with a couple of my own hacks),
in preference to the current evolving ed.  Since "ed" is seldom
used within shell scripts, and when so used, is never that I've
noticed used in a way that depends on which version of "ed"
is used, I don't need to rename my preferred, archaic, "ed".

But, perhaps L. A. Walsh might choose to do with "grep" as I have
done with "ed" ... put an old version ahead of the current version
on $PATH.

(wave to "law" ... hope you're doing well.)

                Paul Jackson

reply via email to

[Prev in Thread] Current Thread [Next in Thread]