How to grep multiple pattern from XML file

Hi Everyone
pls if anyone can help me in writing a script or correcting it what I have done.

I want to write a script to grep record number for all those record which have abc xyd cat dog in one of the field say VALUE, I have thousand of file in a dir and I want to search every file for mathching pattern in field VALUE ,I was trying to give path of dir from command prompt.

#!/bin/sh
filePath=$1;
for i in `ls $filepath`
do
  for y in `grep -il patternfile $filepath$i`
  do
    echo "processing file $y"
    egrep "<RecordNumber>" $y >>metafile.txt
  done
done

Thanks

What is the error you face in this ?

Or what stops you from achieving wht you require ?

My script is not searching in every file in a dir for the multiple pattern which I have saved to a pattern file. Is there a another way to solve the problem . I think I am doing something wrong in looping . It is not searching everyfile in a dir.
pls help me if anyone solve this or figure it out.

Thanks

correct the capital P in filePath in line 2

put a / between $filepath and $i in line 5 - unless you always give param 1 with a trailing /

You could also try ls -1 to make sure the filenames come out on separate lines.

You need to find those files which include something and if include then find some other line ?

You can use filegeneration, no need to use ls.

But in this case, you can use grep, no need to make fileloop.

filepath="$1"
grep -il "VALUE"  $filepath/* | while read file
do
    grep "<RecordNumber>" $file >>metafile.txt
done

If you need also files begin ., then something like

grep ... $filepath/* $filepath/.[!.]*  | ...

If you need more rule (=OR)
then
grep -il -e "pattern1" -e "pattern2"
or write rule to the file and then
grep -il -f patternfile ...

If you need AND patterns, then you need to pipe grep commands.

Example input data and example output data is the best method to tell us your real needs.

Thanks all for replying back
my files(1000 of them ) in dir. My data lin file is ike this

<meta:term-type>PUB_SEG_TYPE</meta:term-type>
<meta:term-source>Atlas</meta:term-source>
<meta:term-id>14242630</meta:term-id>
<meta:term-value>Article</meta:term-value>

I want to get all the record number for those record where <meta:term-source> is list, table, abc, photograph.

Thanks

Do you mean some thing like this:

 
awk '/<meta:term-source>/' * | egrep "list|table|abc|photograph"