A Powerful Text Search Utility:Grep<br />Alibaba.com-Tech-QA-ICBU  Jay<br />
Agenda <br />What’s Grep ?<br />Howto use Grep ?<br />How Grep solve our problems?<br />And Grep for Windows ??<br />It’s ...
What’s Grep ?<br />grep is a command line text search utility originally written for Unix. <br />An Acronym for: globalreg...
Usage of grep: Basic(1)<br /> grep [options] PATTERN [FILE...]<br />	 grep [options] [-e PATTERN | -f FILE] [FILE...]<br /...
Usage of grep: Basic(2)<br />Example3: grep  apple* grepTest.txt <br />Example4: grep  apple. grepTest.txt<br />Example5: ...
Usage of grep: Basic(3)<br />Example7: grep  apple* /home/admin -r<br />Example8: grep search commons -r | grep search<br ...
Usage of grep: regular expression<br />Example1: grep "[Ee]xception" grepTest.txt <br />Example2: grep "^[a-z].*[1-9]" gre...
How to solveourproblems ?<br />Grep configuration fromourcommonantx.properties<br />e.g.  grepbsscommons -r | grep port | ...
Grep for Windows<br />Download: http://gnuwin32.sourceforge.net/packages/grep.htm<br />Installation: As any other software...
SHOW Time<br />
Q & A<br />
Upcoming SlideShare
Loading in...5
×

Grep: A Powerful Text Search Utility

1,732
-1

Published on

Grep: A Powerful Text Search Utility
An introducation for Grep, a Unix Tool.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,732
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
58
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Grep: A Powerful Text Search Utility

  1. 1. A Powerful Text Search Utility:Grep<br />Alibaba.com-Tech-QA-ICBU Jay<br />
  2. 2. Agenda <br />What’s Grep ?<br />Howto use Grep ?<br />How Grep solve our problems?<br />And Grep for Windows ??<br />It’s SHOW time.<br />Q &A<br />
  3. 3. What’s Grep ?<br />grep is a command line text search utility originally written for Unix. <br />An Acronym for: globalregular expressionprint<br /> global search regular expression(RE) and print out the line<br />The grep command searches files or standard input globally for lines matching a given regular expression, and prints them to the program's standard output.<br />variants of grep: egrep,fgrep<br />
  4. 4. Usage of grep: Basic(1)<br /> grep [options] PATTERN [FILE...]<br /> grep [options] [-e PATTERN | -f FILE] [FILE...]<br />Example1: grep error grepTest.txt <br />Example2: grep ERROR grepTest.txt<br />case insensitive; using-i to ignore case<br />e.g. : grep -i error grepTest.txt <br />
  5. 5. Usage of grep: Basic(2)<br />Example3: grep apple* grepTest.txt <br />Example4: grep apple. grepTest.txt<br />Example5: grep apple /home/admin/*<br />Example5: grep -v apple grepTest.txt <br />-v, --invert-match<br />Invert the sense of matching, to select non-matching lines.<br />
  6. 6. Usage of grep: Basic(3)<br />Example7: grep apple* /home/admin -r<br />Example8: grep search commons -r | grep search<br />Example9:cat grepTest.txt | grep apple<br />Example10: ps -ef | grepmyalibaba| grep -v grep<br /> -R, -r, --recursive<br />Read all files under each directory, recursively<br />pipeline(|): the output of each process (stdout) feeds directly as input (stdin) to the next one<br />
  7. 7. Usage of grep: regular expression<br />Example1: grep "[Ee]xception" grepTest.txt <br />Example2: grep "^[a-z].*[1-9]" grepTest.txt <br />Example3: grep ".*.com" grepTest.txt <br />Example4: grep "go{3,5}gle.*" grepTest.txt<br />Just some examples; for more info, learn by yourselves.<br />
  8. 8. How to solveourproblems ?<br />Grep configuration fromourcommonantx.properties<br />e.g. grepbsscommons -r | grep port | grep -v .svn<br />Grep process from ps command<br />e.g. ps -ef | grep charge1 | grep -v grep<br />Grep some keywords from source code<br />e.g. grep -i "companyId.*<.*0" ~/work/intl-site/ -r<br />And others …<br />
  9. 9. Grep for Windows<br />Download: http://gnuwin32.sourceforge.net/packages/grep.htm<br />Installation: As any other software for Win32<br />Usage: Add Grep’s bin-DIR to %PATH%;<br /> Open the command line;(start--run--”cmd”)<br />Use grep as a command line in linux<br />This tool is a program of the GnuWin32 project.<br />
  10. 10. SHOW Time<br />
  11. 11. Q & A<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×