Answers for "linux grep string but show next lines"

0

how to print next lines with grep

grep -A 2 "searchText" mytext.txt ## next 2 lines after match line
grep -B 2 "seacrchText" mytext.txt ## next 2 lines before match line
grep -C 2 "searchText" mytext.txt ## next 2 lines before and after match line
Posted by: Guest on October-03-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language