Mail Archives: djgpp/2001/08/11/02:31:23
Eric Rudd wrote:
>
> grep "string" file
>
> it lists to the screen just fine. If I try to pipe it through "more"
>
> grep "string" file | more
>
> the DOS line terminators change to Unix line terminators, and the screen
> output is a mess. The same problem exists with file redirection
This is a feature: the DJGPP port of Grep preserves the end-of-line format
of the original file, except when its stdout is the console device (because
switching the console device to binary mode has unpleasant side-effects).
It does so because a filter should not alter the file more than it was asked
to; in particular, if Grep doesn't modify the input at all (i.e., all its
lines match), the output should be binary-identical to input.
As for viewing the output, don't use `more'; use Less, which is more than
`more' ;-). Less can handle Unix and DOS end-of-line format with equal
grace.
Note that you would have the same trouble viewing the original file with
`more'.
- Raw text -