Summary


In this lesson, we covered the fundamentals of regular expressions, better known as REs. Regular expressions are an extremely flexible way of describing a pattern to be matched. Because many Unix applications, including the shell, support REs, it is important to develop a general understanding of how they work and what they are used for. With people relying on Unix (or Linux) as their server system or desktop of choice, knowing some of the power you can unleash will aid you in finding areas you need to study deeper, and this is definitely one of them. This lesson was designed to provide enough background for you to begin your true journey into using REs, programming languages like Perl, and beyond into the next lesson's topic: shell scripting with Unix. Here's a review:

  • . This matches any character. Use it whenever you aren't sure what character falls in a specific position.

  • * Using the * matches any number of occurrences of a specific pattern. You can use this in conjunction with . or with ranges.

  • \ Special characters need to be escaped using the \character. If you need to use the quote character (") in a pattern, you'll have to escape it.

  • Ranges You can match ranges of numbers or letters to limit a pattern. Ranges are enclosed in [] characters. To negate a range, use ^ at the beginning of the range specification.

  • ^/$ These two special characters match the beginning and end of a line, respectively. They are commonly referred to as anchors because they hold a pattern to a specific place on a line.

  • Regular expressions These are used in many Unix programs, and can be an extremely powerful tool. Read the man pages for your shell and other utilities in order to determine the extent to which they support regular expressions.



    SAMS Teach Yourself Unix in 10 Minutes
    Sams Teach Yourself Unix in 10 Minutes (2nd Edition)
    ISBN: 0672327643
    EAN: 2147483647
    Year: 2005
    Pages: 170

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net