thanks man, it really works, but can you please provide me code to display the contents of next line, actually i was thinking that i could store this number in variable & then use
sed -n "vp" file
where v is the output from the code + 1 you provided, but it is not working . any alternative please
Thanks man but it is not working. In case of sed it gives me following message
sed: -e expression#1, char3 : expected newer vesrion of sed.
for command
set v=8
sed -n '$vp' file
---------- Post updated at 01:47 PM ---------- Previous update was at 12:51 PM ----------
Can you please tell me if i have to print specific line number from the found pattern. Eg, if i have found pattern on line 6 , i need to print next to next line or say third line from the found pattern
Hi sarbjit,
sed -n "$vp" file won't work as shell will search for value of vp variable instead of variable v. Try this.
sed -n "${v}p" file
Also if you have multiple matches of the search string & you need line no of first match try this:
v=`awk '/searchtext/{print NR ; exit}' file`