lecture7 - Intro to Regexps RegExp Specics Lecture 7:...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Intro to Regexps RegExp Specifics Lecture 7: Regular Expressions CS2042 - UNIX Tools October 15, 2008 Lecture 7: Regular Expressions
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Intro to Regexps RegExp Specifics Meet Grep Meet RegExps Lecture Outline 1 Intro to Regexps Meet Grep Meet RegExps 2 RegExp Specifics Basic RegExp Syntax RegExp Repetition Special Characters Lecture 7: Regular Expressions
Background image of page 2
Intro to Regexps RegExp Specifics Meet Grep Meet RegExps Grep Let’s say we have a large record of user logons. How could we find the history of a single user? Searching Text grep < string > [file] Searches [file] for all lines containing < string > grep -v < string > [file] Searches [file] for all lines NOT containing < string > Lecture 7: Regular Expressions
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Intro to Regexps RegExp Specifics Meet Grep Meet RegExps More Grep Using grep on a file: Example: grep ”logging” /var/log/up2date Shows server’s logins to up2date server Using grep with piped input: Example: history | grep grep When have I used grep recently? Lecture 7: Regular Expressions
Background image of page 4
Intro to Regexps RegExp Specifics Meet Grep Meet RegExps Lecture Outline 1 Intro to Regexps Meet Grep Meet RegExps 2 RegExp Specifics Basic RegExp Syntax RegExp Repetition Special Characters Lecture 7: Regular Expressions
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Intro to Regexps RegExp Specifics Meet Grep Meet RegExps Intro to RegExps Occasionally we need to search for less specific strings. For example, your address book catches fire - why not search your saved e-mail for anything formatted like an address? We can do this (fairly) easily using RegExps! What is a RegExp? Stands for ”Regular Expression” Similar to wildcard strings, but more powerful Also uses different syntax (sorry!) Lecture 7: Regular Expressions
Background image of page 6
Intro to Regexps RegExp Specifics Meet Grep Meet RegExps Scope RegExps are used all over the place. We’ve already seen grep , which takes RegExp search strings. Later we’ll see some other fun commands which use them. search documents in emacs/vi write scripts in Perl/Python/Ruby/. ..
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/23/2009 for the course CS 2042 taught by Professor Mccourt during the Fall '08 term at Cornell University (Engineering School).

Page1 / 21

lecture7 - Intro to Regexps RegExp Specics Lecture 7:...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online