CSDN博客

img symield

grep

发表于2004/9/20 10:00:00  652人阅读

分类: shell

1)$ grep -n '^south' datafile

    3:southwest    SW      Lewis Dalsass          2.7

2)$ grep -i 'pat' datafile

     Pat     Huang                  yuanxiao

    ps: The -i option turns off case sensitivity (nomatter lowercase or uppercase ).

3)$grep -v 'Li' datefile

  ps:The -v option prints all lines not contain the pattern 'Li'.

4)$grep -l 'SE' *

  ps: The -l option only prints the filenames where the pattern is found.

5)$grep -c 'west' datafile

  ps:The -c option causes grep to print how much lines which

       matches the pattern .(but if the pattern matches three times in a line, it

       only count  one time)

6)$grep -w 'north' datafile

   ps:The -w option causes grep to find the pattern only if it is a word, not

        part of word. only the line contain the word north is printed, not  

        northwest.

 

summary:grep can used combine with regular expression, so it's a powerful

              tool of unix.

              grep [-v] [-l] [-w] [-c] [-] [] [] [] [] [ ]

 

0 0

相关博文

我的热门文章

img
取 消
img