Grep Multiple Strings

Hi,

Can any one pelase tell me how to grep multiple strings from multiple files in a singel folder?

grep -E "string1|string2|string3|string4|string..."

its taking lots of time..

can any please tell me fast grep???
URGENT

If files are big and too many then it will take time..
you can try awk version

awk '/string1/||/string/||...{print}' filenames

Hi,
There are multiple files,can we search in the folder or directory?

awk '/string1/||/string/||...{print}' filenames

put * in place of filenames to search multiple files

Yaa igot them,but iwant to take only one occurence for string.

one occurence??
you mean exact match or only the first match??

i have multiple records matching with the strings given,i want only 1 record matching.

from all the filea??
its better you provide some sample i/p and o/p

just an added question. how can i search for multiple strings and print the next string after the "found string"? thanks!

Can you provide an example?

my working file looks like this:

<empty>
<empty>
<empty>
NAME :ABC AGE :15
GENDER :MALE
<other strings>
<other strings>
NAME :DEF AGE :18
GENDER :FEMALE
<other strings>
<other strings>
NAME :GHI AGE :5
GENDER :FEMALE
<other strings>
<other strings>

output file should be:
ABC|15|MALE
DEF|18|FEMALE
GHI|5|FEMALE

i used this code:

awk -n 'data.awk > output

data.awk looks like this

{
if (substr($1,1,4) == "NAME")
{
name = substr($2,2) ; age = substr($4,2)
}
if (substr($1,1,6) == "GENDER")
{
gender = substr($2,2)
}
print name"|"age"|"gender
}

but it outputs like this:
||
||
ABC|15|MALE
ABC|15|MALE
ABC|15|MALE
ABC|15|MALE
DEF|18|FEMALE
DEF|18|FEMALE
DEF|18|FEMALE
DEF|18|FEMALE
GHI|5|FEMALE
GHI|5|FEMALE
GHI|5|FEMALE
GHI|5|FEMALE
||
||

what could be the problem?

---------- Post updated at 05:28 PM ---------- Previous update was at 05:26 PM ----------

im sorry, i forgot to disable smilies... that smiley is :smiley:

---------- Post updated at 05:37 PM ---------- Previous update was at 05:28 PM ----------

is this code valid?

awk '/NAME/{print ($2,2)}||/AGE/{print ($4,2)}||/GENDER/{print ($2,2)}'input_file >>output_file

---------- Post updated at 06:38 PM ---------- Previous update was at 05:37 PM ----------

pls help me on this...

---------- Post updated at 06:38 PM ---------- Previous update was at 06:38 PM ----------

can anyone help me