Answers for "grep lines after"

2

grep lines after match

$ grep -A1 text

-AX tells grep to display 'X' amount of lines after line of match. 
Use -BX to do the same but before.
Posted by: Guest on September-29-2021
1

grep count lines

cat -n myfile
Posted by: Guest on October-14-2020
1

lines before and after grep

You can use the -B and -A to print lines before and after the match.

grep -i -B 10 'error' data
Will print the 10 lines before the match, including the matching line itself.
Posted by: Guest on April-21-2021

Browse Popular Code Answers by Language