# GREP function in ksh which ignores LINE Breaks

**URL:** <https://community.unix.com/t/grep-function-in-ksh-which-ignores-line-breaks/346476>\
**Category:** How to Post in the The UNIX and Linux Forums\
**Created:** [September 19, 2014, 3:59pm UTC](https://community.unix.com/t/grep-function-in-ksh-which-ignores-line-breaks/346476 "2014-09-19T15:59:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raghav\_Garg](https://community.unix.com/letter_avatar/raghav_garg/32/5_5575768a8748004e209b776fc1b2916d.png) [@Raghav\_Garg](https://community.unix.com/u/Raghav_Garg)\
**Post date:** [September 19, 2014, 3:59pm UTC](https://community.unix.com/t/grep-function-in-ksh-which-ignores-line-breaks/346476/1 "2014-09-19T15:59:40Z")

</div>

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:-

```nohighlight
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

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [September 19, 2014, 4:03pm UTC](https://community.unix.com/t/grep-function-in-ksh-which-ignores-line-breaks/346476/2 "2014-09-19T16:03:19Z")

</div>

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

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

a

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

b

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

$

```

---

<div class="post-metadata">

**Author:** ![Raghav\_Garg](https://community.unix.com/letter_avatar/raghav_garg/32/5_5575768a8748004e209b776fc1b2916d.png) [@Raghav\_Garg](https://community.unix.com/u/Raghav_Garg)\
**Post date:** [September 19, 2014, 4:05pm UTC](https://community.unix.com/t/grep-function-in-ksh-which-ignores-line-breaks/346476/3 "2014-09-19T16:05:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [September 19, 2014, 4:10pm UTC](https://community.unix.com/t/grep-function-in-ksh-which-ignores-line-breaks/346476/4 "2014-09-19T16:10:08Z")

</div>

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