Chapter 6

Regular Expressions

This chapter’s learning objectives are

  • To understand the use of regular expressions
  • To understand the usage of the metacharacters of regular expressions
  • To understand how to apply each of the metacharacters
  • To be able to use grep/egrep to search for files for strings
  • To be able to use the basic forms of sed and awk to solve search problems

6.1 Introduction

A regular expression (regex) is a string that expresses a pattern used to match against other strings. The pattern will either match some portion of another string or not. We can use regular expressions to define pattern matching rules which can then be used by programs. For instance, regular expressions are applied in software that performs spam filtering ...

Get Linux with Operating System Concepts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.