[lug] finding text lines in a single file

Dave Treece davet at frii.com
Tue Apr 27 19:58:57 MDT 2004


Not sure if anyone has suggested this but, have you tried:

  grep -f EntryFile LogFile

> -----Original Message-----
> From: lug-bounces at lug.boulder.co.us
> [mailto:lug-bounces at lug.boulder.co.us]On Behalf Of Wagner, Carl
> Sent: Tuesday, April 27, 2004 1:04 PM
> To: Boulder (Colorado) Linux Users Group -- General Mailing List
> Subject: [lug] finding text lines in a single file
> 
> 
> Hi,
> 
> I know someone can answer this in about 10 seconds, but I am 
> having a brain lock.
> 
> I have a text file with 1 entry per line.  I want to grep a file 
> for each successive entry, using
> a bash/ksh script.
> 
> 
> Example:
> EntryFile
>    123
>    124
>    125
>    126
> 
> I want to grep for each entry in a single log file
>    grep 123 LogFile
>    grep 124 LogFile
>    grep 125 LogFile
>    grep 126 LogFile
> 
> I tried 
>   grep `xargs -n 1 -t < EntryFile` LogFile
> But that is looking for a file named 123
> 
> I tried 
> 	xargs -n 1 -t < EntryFile egrep LogFile
> but that is not what I wanted either.
> 
> Basically what I want is 
>   open EntryFile
>   while not EndOfFile(EntryFile)
>   {
>    EntryLine = read EntryFile
>    grep EntryLine LogFile
>   }
> 
> 
> I could do this easily in c, but I need to be able to do it in a script.
> 
> Thanks,
> Carl.
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us portf67 channel=#colug
> 



More information about the LUG mailing list