[GLLUG] grep help

STeve Andre' andres at msu.edu
Wed May 11 15:16:29 EDT 2005


Well, the fastest thing might be

    grep blah blah blah > /tmp/fyle
    head -1 /tmp/fyle
    tail -3 /tmp/fyle
    rm -f /tmp/fyle

On Wednesday 11 May 2005 15:10, Mike Szumlinski wrote:
> Actually, almost there.  I also want the first line as well as the last
> 3 of each file.
>
> On May 11, 2005, at 3:06 PM, STeve Andre' wrote:
> > If I am understanding you, then all you want is the last three lines
> > of output?  If that is the case, you can use the tail command, like so
> >
> >    grep blah blah blah | tail -3
> >
> > The cool cool thing about the shell is that you have all these little
> > programs, like grep, head, tail, awk, sed, cut, etc that are tools
> > that do on thing, which can be tacked together for a custom tool.


More information about the linux-user mailing list