Skip to Content
Mastering Linux Shell Scripting - Second Edition
book

Mastering Linux Shell Scripting - Second Edition

by Mokhtar Ebrahim, Andrew Mallett
April 2018
Beginner
284 pages
7h 3m
English
Packt Publishing
Content preview from Mastering Linux Shell Scripting - Second Edition

Using grep

If we wanted to talk properly about grep, an entire book would not be enough. grep supports many engines along with BRE and ERE. It supports engines such as Perl-compatible regular expression (PCRE).

The grep is a very powerful tool that most system administrators use every day. We just want to enlighten the point of using BRE and ERE patterns as we did with sed and AWK.

grep tool understands BRE patterns by default, and if you want to use ERE patterns, you should use the -E option.

Let's work with the following example file and use a BRE pattern:

Welcome to shell scripting.love shell scripting.shell scripting is awesome.

Let's test a BRE pattern:

$ grep '.sh' myfile

The results are colored in red.

Let's test an ERE pattern:

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting - Second Edition

Learning Linux Shell Scripting - Second Edition

Ganesh Sanjiv Naik
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781788990554Supplemental Content