GREP function in ksh which ignores LINE Breaks

I am using a grep command with two patterns in my KSH script. File has line breaks in it and both the patterns are in different lines. Here is the command - grep -l 'RITE AID.*ST.820' natriter820u.20140914

Pattern1 - RITE AID
Pattern2 - ST*820

I am not getting any results from this, whereas if I replace this file with a different file having no line breaks then it works. Is there any work around to deal with line breaks here.

Here is the sample data:-

ISA*00* 00 *ZZ*NATIONSBANK *14*0030020520500 *140918*1200*U*00401*000006436*0*P*^ 
GS*RA*014578892*IGIHCJEEJ*20140918*1200*6442*X*004010
ST*820*000006482 
N1*PR*RITE AID HDQTRS. CORP.*1*014578892

Can someone please help.

Thanks

What output do you want from this? Do you just want to match both lines?

$ echo "a" | grep "a\|b\|c"

a

$ echo "b" | grep "a\|b\|c"

b

$ echo "z" | grep "a\|b\|c"

$

I just need the file name having both of these patterns but line break is posing a problem I believe.

You have posted in the wrong forum. I will continue in your 'good' thread.

1 Like