Created
August 23, 2013 10:33
-
-
Save pmgupte/6317849 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to get matching line and 5 lines before that | |
grep -B 5 "pattern" file | |
# to get matching line and 5 lines after that | |
grep -A 5 "pattern" file | |
# of course, you can combine -A and -B options together in single command. That's obvious. | |
# if your -A and -B values are same, you need not specify both the options. use -C instead. | |
grep -C 5 "pattern" file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment