Chapter 10

  1. What is a search pattern?
    A regular expression syntax which allows us to find pieces of text with specified characteristics, such as length, content and location on a line.
  2. Why are regular expressions considered greedy?
    Most regular expression try to find as much data as they can that match the search pattern. This includes whitespace and other punctuation, which is a logical separation for humans but not necessarily for a machine.
  3. Which character in search patterns is considered a wildcard for any one character, except newlines?
    The dot (.).
  4. How is the asterisk used in Linux regular expression search patterns?
    The * is used in combination with another character to allow it to form a repeating character. Example search pattern: spe*d will match spd, sped, speed, speeeeeeeeed, and so on.
  5. What are line anchors?
    The special characters used to denote line beginnings and endings. ^ for the beginning of the line, $ for the line end.
  6. Name three character types.
    Any of these are correct:
    • alphanumeric
    • alphabet
    • lowercase
    • uppercase
    • digits
    • blanks
  7. What is globbing?
    Globbing is accomplished when you use a * or ? on the command-line when interacting with files or file paths. Globbing allows us to easily manipulate (move, copy, delete, and so on) files that are matched on the globbing pattern.
  8. What is possible in the extended regular expression syntax, that is not possible with normal regular expressions under Bash?
    • One or more repeating characters
    • Exact number of repeating characters
    • Range of repeating characters
    • Alternation with more than a single character
  9. What would be a good rule of thumb between deciding to use grep or sed?
    If your goal can be achieved with a single grep statement, choose simplicity. If it cannot be achieved in that manner, choose sed for more powerful syntax.
  1. Why are regular expressions on Linux/Bash so hard?
    There are many different implementations that are similar. With regular expressions and their difficulty as-is, this confusion does not help. Only practice and experience will remedy this!