From the course: Complete Guide to Navigating Linux: Working with Users, Files, and Networks

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

A primer to regular expressions

A primer to regular expressions

- In this video, we'll do an introduction to a regular expressions. A regular expression is a flexible search pattern. And you use it in text processing utilities like grep. Regular expressions are powerful, but also a bit confusing, because different sets of regular expressions exist. But I recommend that you know a bit about the basics. So, let's talk about some essential regular expressions. The anchor, caret, refers to beginning of the line. So if you would use grep '^l' on myfile, you print lines that start with an l. Notice how the regular expression is written? It should be between single quotes. And that is to avoid interpretation problems. That's because in a regular expressions, you will have characters that also have special meaning in the shell! Like the dollar! Which in a regular expression is referring to the end of the file. Or the dot, which in the regex, refers to a single character! Here, you can see grep '^.$' which means that we are looking for files that have one…

Contents