꽃선생 2015. 4. 30. 10:59

grep [-옵션] 패턴 파일명 

grep [OPTIONS] PATTERN [FILE...]

 

-c : 패턴이 일치하는 행의 수를 출력 

 -c, --count
              Suppress normal output; instead print a count of matching lines for each input file.  With the -v, --invert-match  option  (see  below),  count  non-matching
              lines.  (-c is specified by POSIX.)

 

-i : 비교시 대소문자를 구별 안함 

 -i, --ignore-case
              Ignore case distinctions in both the PATTERN and the input files.  (-i is specified by POSIX.)

 

-v : 지정한 패턴과 일치하지 않는 행만 출력 

-v, --invert-match
              Invert the sense of matching, to select non-matching lines.  (-v is specified by POSIX.)

 

-n : 행의 번호를 함께 출력 

-n, --line-number
              Prefix each line of output with the 1-based line number within its input file.  (-n is specified by POSIX.)

 

-l : 패턴이 포함된 파일의 이름을 출력 

 -l, --files-with-matches
              Suppress normal output; instead print the name of each input file from which output would normally have been printed.  The scanning will stop  on  the  first
              match.  (-l is specified by POSIX.)

 

-w : 패턴이 전체 단어와 일치하는 행만 출력 

-w, --word-regexp
              Select only those lines containing matches that form whole words.  The test is that the matching substring must either be at the beginning of  the  line,  or
              preceded  by  a  non-word constituent character.  Similarly, it must be either at the end of the line or followed by a non-word constituent character.  Word-
              constituent characters are letters, digits, and the underscore.