• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Grep: A Powerful Text Search Utility

Grep: A Powerful Text Search Utility



Grep: A Powerful Text Search Utility

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



Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Grep: A Powerful Text Search Utility Grep: A Powerful Text Search Utility Presentation Transcript

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