Searching multiple files with multiple expressions

I am using a DEC ALPHA running Digital UNIX (formly DEC OSF/1) and ksh. I have a directory with hundreds of files that only share the extension .rpt. I would like to search that directory based on serial number and operation number and only files that meet both requirements to be printed out. I am new to scripting and have been try to do this with grep but have not had much luck.

here is a sample of the file: (120205462.rpt)
_________________________________
S/N: 10001 Name: ESSM GS Acceptance Operation: 300
-----------------------------------------------------

Try:

egrep
awk

do a man and see which one best suits your needs. I am partial to awk.

I am using egrep right now:

ser="10001"
oper="300"

egrep -l "$ser" *.rpt|egrep -l "$oper" *.rpt

this works but it also shows files that have an operation other then 300

Hmm.. I created two test files with

S/N: 10001                  Name: ESSM GS Acceptance                    Operation: 300

in one and

S/N: 10001                  Name: ESSM GS Acceptance                    Operation: 400

in the other.

When I ran your code, it only listed the first file with 300 in it. Are you sure the number 300 doesn't occur anywhere else in the files that don't have an operation code of 300? The same with the serial numbers I suppose... if you're searching for files with a serial number of 10001, you could end up displaying files with a serial number of 3010 but which have 10001 somewhere else in the file...

I short handed the last bit of code because :

ser="S/N: 10001"
oper="Operation: 300"

I did this because there are chances of having 300 and 10001 in the collected data. using this and the egrep statement I get several operation 190's that have the serial number of 10001.

egrep -l "$oper" `egrep -l "$ser" *.rpt`

Using the above suggestion gives me an error.

grep: egrep -l "$ser" *.rpt: cannot open [No such file or directory]

anymore ideas.

Thanks Perderabo