bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: grep feature request: print all lines


From: Stepan Kasal
Subject: Re: grep feature request: print all lines
Date: Sat, 23 Oct 2004 16:51:10 +0200
User-agent: Mutt/1.4.1i

Hello,

On Fri, Oct 22, 2004 at 04:21:06PM +0200, Egmont Koblinger wrote:
> However, I really miss one feature: to print all the lines.

sorry, I don't think grep should support that.

Some simple tasks can be done by current grep:

> - Coloring could still be performed for matches, e.g.
>     grep --print-all-lines --color=auto pattern file
>   would print the whole file to my terminal with highlighting strings that
>   match the given pattern.

Use
        grep --color=auto -e pattern -e '' file

> - Line numbering, file name prefixing for lines etc. still could be
>   performed.

This can be done similarily.

> - The return value could reflect whether a match was found.

The exit code is spoiled by the previous trick.  You have to run

        grep -q pattern file

separately.  "grep -q" will end on first match, so you won't loose
much time if the first match is reasonably near the beginning of the file.

If this is not enough, gawk is your friend.

Sorry,
        Stepan Kasal




reply via email to

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