Reputation:
aaa aaaa aaaa aaaa
sss ssss ssss ssss
ddd dddd dddd dddd
fff ffff ffff ffff
abc pattern asd fde
111 222 333 444 555
666 777 888 999 000
Desired output : If the
111 222 333 444 555
666 777 888 999 000
Upvotes: 7
Views: 16963
Reputation: 289505
Just set a flag whenever the pattern is found. From that moment on, print the lines:
$ awk 'p; /pattern/ {p=1}' file
111 222 333 444 555
666 777 888 999 000
Or also
awk '/pattern/ {p=1;next}p' file
It looks for pattern
in each line. When it is found, the variable p
is set to 1. The tricky point is that lines are just printed when p>0
, so that the following lines will be printed.
This is a specific case of How to select lines between two patterns? when there is no such second pattern.
Upvotes: 13
Reputation: 195029
sed '1,/pattern/d' file
works for your example.
sed '0,/pattern/d' file
is more reliable.
Upvotes: 8