1 / 17

GNU Grep

GNU Grep. What is GNU?. GNU  is an operating system which is 100% free software. It was launched in 1983 by Richard Stallman and has been developed by many people working together for the sake of freedom of all software users to control their computing

Download Presentation

GNU Grep

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GNU Grep

  2. What is GNU? • GNU is an operating system which is 100% free software. • It was launched in 1983 by Richard Stallman and has been developed by many people working together for the sake of freedom of all software users to control their computing • It works as a free software foundation  of open source tools. • Check this websit https://www.gnu.org/software/

  3. What is Grep? • Grep (Global Regular Expression Print) searches one or more input files for lines containing a match to a specified pattern. By default, Grep outputs the matching lines. • Is installed by default on almost every distribution of Linux, BSD and UNIX, and is even available for Windows. • Download from: http://gnuwin32.sourceforge.net/packages/grep.htm

  4. GREP • There are two ways to provide input to Grep, each with its own particular uses. • First, Grep can be used to search a given file or files on a system (including a recursive search through sub-folders). • Grep also accepts inputs from another command or series of commands.

  5. Regular expressions • A regular expression, often shortened to “regex” or “regexp”, is a way of specifying a pattern (a particular set of characters or words) in text that can be applied to variable inputs to find all occurrences that match the pattern. •  regular expressions are included in the Grep command in the following format:

  6. Environment variable • An environment variable is a dynamic "object" on a computer that stores a value, which in turn can be referenced by one or more software programs in Windows.  • In other words it stores a reference for the regularly used software tools in one path.

  7. How to add grep to environment variable

  8. Grep Commands • Open The CMD, Write the command grep • Grep –help briefly summarizing the command-line options

  9. Grep Commands • Create a txt file on which we will run our Grepsearches • the file contains the following lines: Hi this is test file to carry out few regular expressions practical with grep 123 456 Abcd ABCD

  10. Try this commands grep -i “abcd” testfile grep -w “test” testfile grep -B2 “Abcd” testfile grep “[a-z]” testfile grep “[A-Z]” testfile

  11. Line and word anchors • The ^ anchor specifies that the pattern following it should be at the start of the line: grep“^th” testfile • The $ anchor specifies that the pattern before it should be at the end of the line: grep“i$” testfile • The operator \> anchors the pattern to the end of a word. grep“le\>” testfile

More Related