print next line if matches a particular word..need help

Hi
i need a help for making a script whch can print next line if it matches a particular word
like file1 have
ename Mohan
eid 2008
ename Shyam
eid 345

if scipt got Mohan it will print next line (eid 2008)

pls help me .......:slight_smile:

try this:

sed -n -e '/Mohan/ {n; p;}' filename

Hi

Thanks for ur reply but have little bit doubt

if i have file
ename Mohan
ename2 Mohan
eid 2008
ename Shyam
eid 345

and i will give sed -n -e '/Mohan/ {n; p;}' filename
it wiil give output
ename2 Mohan

here when command finds Mohan it is prinitng next line ename2 Mohan but it should also print eid 2008 as file is also having line ename2 Mohan