Search from file and display

Dear All

I had input file as mention below. Now from that file i want to search string "FAULT CODES CLASS" and want to display contain again its. ( ie. 1B4 --4 is in next line. ).

Kindly let me know the possible ways.

<rxmfp:mo=RXOTX-46-5 ;
RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT FAULT INFORMATION

MO BTSSWVER
RXOTX-46-5 ERA-G04-R11-V01

RU RUREVISION RUSERIALNO
0

RUPOSITION                           RULOGICALID                       

STATE BLSTATE INTERCNT CONCNT CONERRCNT LASTFLT LFREASON
NOOP BLO 00000

FAULT CODES CLASS 1B
4

END

<

regards
Jaydeep Sadaria

if you have Python, here's an alternative:

#!/usr/bin/env python
f=open("file")
for line in f:
    line=line.strip()
    if "FAULT CODES CLASS" in line:
        line=line+f.next()
        print line.split()[-1]
        

output:

# ./test.py
1B4

You could also use grep,nawk and tr commands ... Assumptions here are you want only IB4 in above example ...

$ vi output.ksh
#!/usr/bin/ksh
i=`grep -n "FAULT CODES CLASS" EXAMPLE.txt | cut -f 1 -d ":"`
j=`expr $i + 1`
nawk "NR==$i || NR==$j" EXAMPLE.txt > EXAMPLE1.txt
tr -d '\n\' < EXAMPLE1.txt | cut -f 4 -d " "

$ ./output.ksh
1B4

awk '/FAULT CODES CLASS/{s=$NF;getline;print s $0}' example.txt

cheers,
Devaraj Takhellambam