From the course: Bash Patterns and Regular Expressions

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using regular expressions with grep

Using regular expressions with grep - Bash Tutorial

From the course: Bash Patterns and Regular Expressions

Start my 1-month free trial

Using regular expressions with grep

- [Instructor] Grep may be the most common tool in Linux to use regular expressions with. In fact, the name grep stands for global regular expression print. Let's talk about some grep options that deal with regular expressions. By default, grep uses BREs, but it supports EREs if you pass the -E option, or you use the egrep command. The egrep command name has been deprecated, but is kept around for historical reasons, as some tools still rely on that name existing. We're going to focus on using EREs with grep in this video. If you're not using GNU Grep, then you may not have access to back-references and EREs, so be aware, you may have to convert these examples to BREs for your version of grep. If you want to force grep to process a regex as a BRE, you can pass the -G option. Perhaps the only way of using Perl-compatible regular expressions in bash is to pass the -P option to grep. This is experimental, and not all features are supported. Normally, the expression is assumed based on…

Contents