Dear Experts,
I have file called file1 in which i am greping a pattern after that i want to next 3 lines when that pattern is matched.
Ex:- file1
USA
UK
India
Africa
Hello
Asia
Europe
Australia
Hello
Peter
Robert
Jo
i want to next 3 lines after matching Hello pattern. i.e output should be.
Asia
Europe
Australia
Peter
Robert
Jo
hi....
Do you want the next three lines or all the lines after the pattern matching.
Your required output shows that you want all the lines after the pattern matching.
Be clear on your requirement first.
#!/usr/bin/perl
open (FH,"blah.txt") || "die can't open file $!";
while (<FH>) {
last if /Hello/ }
my ($curr, $next1, $next2, $next3)=<FH>;
close FH;
print "$curr$next$next2$next3";