alwbtc alwbtc - 4 months ago 16
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

You can tail it, then grep:

tail -n +50000 myfile.txt | grep -in "time spent"