[Cialug] grep question

chris at bynw.com chris at bynw.com
Fri Apr 17 16:54:07 UTC 2020


I think I might have some syntax incorrect.

The basics is:
file2read.txt each line has text to search for not regex

so I'm using fgrep

fgrep -f file2read.txt -r /directory/* > write2find.txt

so I want to search all files in the directory for the text in the 
file2read.txt

right now it writing everything from the directory in to the output text 
file



On 2020-04-17 01:09, Tim Wilson wrote:
> 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
>> 


More information about the Cialug mailing list