Basic regular expressions

You have a problem and you want to solve it with regular expressions? Now you have two problems! This is just one of the many regular expression jokes on the Internet.

In this section, you will learn how regular expressions work, as we will be using them in the upcoming chapters. We have prepared a file for our playground and if you want to try the grep commands on your own, you can take it from the GitHub repository.

Let's start by opening our text file so we can see its contents, and then splitting the screen so we can see both the file and the command side by side.

First of all, the simplest and probably the most common regular expression is to find a single word.

For this we will use the grep "joe" file.txt command: ...

Get Working with Linux – Quick Hacks for the Command Line 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.