Search String and extract few lines under the searched string

Need Assistance in shell programming... I have a huge file which has multiple stations and i wanted to search particular station and extract few lines from it and the rest is not needed

Bold letters are the stations . The whole file has multiple stations .
Below example i wanted to search KSZ063 and get the below 6 lines to it.

Ex sample file


KSZ077-082200-
GRAY-
INCLUDING THE CITIES OF...CIMARRON...MONTEZUMA
900 AM CST WED JAN 8 2014

.REST OF TODAY...CLOUDY. HIGHS AROUND 30. NORTH WINDS 10 TO
15 MPH WITH GUSTS TO AROUND 25 MPH.
.TONIGHT...MOSTLY CLOUDY. LOWS AROUND 14. NORTH WINDS UP TO 5 MPH
SHIFTING TO THE SOUTHWEST AFTER MIDNIGHT.
.THURSDAY...MOSTLY SUNNY. HIGHS IN THE MID 30S. SOUTH WINDS 5 TO
15 MPH.

$$

KSZ063-082200-
FINNEY-
INCLUDING THE CITIES OF...GARDEN CITY...KALVESTA
900 AM CST WED JAN 8 2014

.REST OF TODAY...CLOUDY. HIGHS AROUND 30. NORTH WINDS 5 TO 15 MPH
WITH GUSTS TO AROUND 25 MPH.
.TONIGHT...MOSTLY CLOUDY. LOWS AROUND 14. NORTHEAST WINDS UP TO
5 MPH SHIFTING TO THE SOUTH AFTER MIDNIGHT.
.THURSDAY...MOSTLY SUNNY. HIGHS IN THE UPPER 30S. SOUTH WINDS
5 TO 15 MPH.

$$


grep -A6 KSZ063 file

It gives me an illegal option. Any ideas of using with awk

$ grep -A6 KSZ063 *.zone
grep: illegal option -- A
grep: illegal option -- 6
Usage: grep -hblcnsviw pattern file . . .
awk '/KSZ063/{f=1}c==7{c=0;f=0}f&&++c<=7' file
1 Like

It works great !!!! Thanks Yoda.