[Cialug] grep question

Tim Wilson tim_linux at wilson-home.com
Fri Apr 17 06:09:22 UTC 2020


Bonus “Pro Tip”: if you only want the text and don’t care about the file
names, use -h.

On Fri, Apr 17, 2020 at 12:42 AM kristau <kristau at gmail.com> wrote:

> I use this all the time. It works exactly as Tim described. Very useful Pro
> Tip!
>
> On Thu, Apr 16, 2020 at 8:27 PM <chris at bynw.com> wrote:
>
> > ah. awesome. thanks Tim. I'll give it a shot.
> >
> > On 2020-04-16 20:11, Tim Wilson wrote:
> > > It stops scanning that file if it finds a match. It will continue
> > > scanning
> > > each file Individually.
> > >
> > > On Thu, Apr 16, 2020 at 7:56 PM <chris at bynw.com> wrote:
> > >
> > >> I was wondering about that. But the man page detail reads:
> > >>
> > >>         -l, --files-with-matches
> > >>                Suppress normal output; instead print the name of each
> > >> input file from which output would normally  have
> > >>                been printed.  The scanning will stop on the first
> > >> match.
> > >>
> > >> which makes me think the scanning will stop while I'm scanning
> > >> multiple
> > >> files and want them all scanned for the matching text.
> > >>
> > >>
> > >>
> > >>
> > >> On 2020-04-16 19:49, Tim Wilson wrote:
> > >> > I think what you’re looking for is -l (lowercase L). Or if you
> prefer
> > >> > the
> > >> > long option, --files-with-matches
> > >> >
> > >> > On Thu, Apr 16, 2020 at 7:33 PM <chris at bynw.com> wrote:
> > >> >
> > >> >> I have a question about using Grep. I have fgrep searching for a
> long
> > >> >> string in several files. It's great it finds them so there is
> nothing
> > >> >> wrong there. Just when I get the results it gives me the file name
> > and
> > >> >> the long string. How do I just get the file name as the output?
> > >> >>
> > >> >> Thanks!
> > >> >>
> > >> >> chris
> > >> >> _______________________________________________
> > >> >> Cialug mailing list
> > >> >> Cialug at cialug.org
> > >> >> https://www.cialug.org/cgi-bin/mailman/listinfo/cialug
> > >> >>
> > >> _______________________________________________
> > >> Cialug mailing list
> > >> Cialug at cialug.org
> > >> https://www.cialug.org/cgi-bin/mailman/listinfo/cialug
> > >>
> > _______________________________________________
> > Cialug mailing list
> > Cialug at cialug.org
> > https://www.cialug.org/cgi-bin/mailman/listinfo/cialug
> >
>
>
> --
> Tired programmer
> Coding late into the night
> The core dump follows
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> https://www.cialug.org/cgi-bin/mailman/listinfo/cialug
>
-- 
Tim
Required reading: http://bccplease.com/


More information about the Cialug mailing list