Wednesday, 22 April 2015

Linux Grep Command


grep "literal_string" filename
 
grep "string" FILE_PATTERN
 
grep -i "string" FILE
 
grep "REGEX" filename
 
grep -iw "is" demo_file
 
grep -A <N> "string" FILENAME
 
grep -B <N> "string" FILENAME
 
grep -C 2 "Example" demo_text 

export GREP_OPTIONS='--color=auto' GREP_COLOR='100;8'
grep this demo_file
 
grep -r "DJ" * 

grep -v "go" demo_text
 
grep -v -e "pattern" -e "pattern"
 
grep -c "pattern" filename
 
grep -v -c this demo_file
 
grep -l this demo_*
 
grep -o "is.*line" demo_file
 
grep -o -b "pattern" file
 
grep -n "go" demo_text