Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

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
 
PREVIOUS NEXT
Tagged: #print #lines #grep
ADD COMMENT
Topic
Name
7+6 =