Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use patterns from file1 to search file2 1

Status
Not open for further replies.

cp2000

Technical User
Dec 31, 2002
81
US
Guess I must be reading the online documentation wrong. I can't see an examp[le of how to do this.

I need to search file2 (a mail log) using patterns in file1. Sample data for file1 is:
FD3034B73
F352D4A70
 
cp2000,

This is not an awk solution, but this should work fine (if I understand what you are trying to achieve).

Code:
#!/usr/bin/ksh

while read line
do
grep $line file2
done<file1

John

 
if you have a POSIX grep (/usr/xpg4/bin/grep under Solaris) you can:

grep -f file file2

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
THNX guys,
That was enough to get me started thru.

NOW - JohnGriggs, if I wanted to clean this up a little, by having the patterns inside my script? I'm doing a gawk to generate file1. Also Im on a Redhat 8 Linux system

TIA

Leon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top