alwbtc alwbtc - 1 year ago 142
Linux Question

How to grep a string after a specified line number?

I have a large text file, I want to see the lines containing

"time spent"
in this text file, I use:

grep -in "time spent" myfile.txt

But I'm interested only in the lines after 50000. In the output I want to see lines after 50000 and that contain "time spent". Is there a way to do this?

Answer Source

You can tail it, then grep:

tail -n +50000 myfile.txt | grep -in "time spent"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download