arrow_back Back to Notebook
linux
linux
February 11, 2019

Get additional lines before and after grep match

To get additional lines before and after the grep match you can add the arg -n

<cmd> | grep <criteria> -n#

For Example

<some command> | grep "criteria" -n5

Thanks for reading!

John Wiseman

Full-Stack Software Engineer building scalable digital solutions. specializing in modern web technologies and mission-critical systems.

© 2026 Wiseman Systems Pty. Ltd.

Navigation

Start a Conversation

Ready to discuss your next project? Let's build something extraordinary together.

Get in Touch