Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

To print from the first line until pattern is matched

$
0
0
Hi I want to print the line until pattern is matched.

I am using below code:

Code:

sed -n '1,/pattern / p' file
It is working fine for me , but its not working for exact match.

Code:

sed -n '1,/^LAC$/ p' file
Input:
Code:

LACC        FEGHRA                0
LACC        FACAF                0
LACC        DARA                0
LACC        TALAC                0
LAC        ILACTC                0
LACC        Kerzner                0
LAAS        TOTAL                0
LACC        LAC                0
LACC        IRSI                0
LACC        Asocianes CTO        0
LACC        Kerzner                0

Expected Output:
Code:

LACC        FEGHRA                0
LACC        FACAF                0
LACC        DARA                0
LACC        TALAC                0
LAC        ILACTC                0


Viewing all articles
Browse latest Browse all 16232

Trending Articles