Grep Command attributes
Recursively Search a sting in current directory
grep -inr 'search-text' .
Search in specific file pattern
grep -inr --include="*txt" "search-text" .
Grep with only first 150 text of lines
grep -inr 'search-text' | cut -c 1-150
Grep multiple text in a single search
grep -e "search1" -e "search2" file.txt
Grep with 5 limes from top and 5 lines from bottom and 5 lines from both top and bottom
Displaying lines before/after/around the match using grep -A, -B and -C -A is the option which prints the specified N lines after the match as shown below. -B is the option which prints the specified N lines before the match. -C is the option which prints the specified N lines before the match. In some occasion you might want the match to be appeared with the lines from both the side. This options shows N lines in both the side(before & after) of match. grep -inr -C 10 'username' . | grep -ie 'exception -ie 'error'