Skip to Content
Linux Shell Scripting Cookbook - Third Edition
book

Linux Shell Scripting Cookbook - Third Edition

by Clif Flynt, Sarath Lakshman, Shantanu Tushar
May 2017
Beginner
552 pages
28h 47m
English
Packt Publishing
Content preview from Linux Shell Scripting Cookbook - Third Edition

There's more...

Let's see a few examples of regular expressions:

This regular expression would match any single word:

( +[a-zA-Z]+ +) 

The initial + characters say we need 1 or more spaces.

The [a-zA-Z] set is all upper– and lower–case letters. The following plus sign says we need at least one letter and can have more.

The final + characters say we need to terminate the word with one or more spaces.

This would not match the last word in a sentence. To match the last word in a sentence or the word before a comma, we write the expression like this:
( +[a-zA-Z]+[?,\.]? +) 

The [?,\.]? phrase means we might have a question mark, comma, or a period, but at most one. The period is escaped with a backslash because a bare period is a wildcard that ...

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

Mastering Linux Shell Scripting - Second Edition

Mastering Linux Shell Scripting - Second Edition

Mokhtar Ebrahim, Andrew Mallett

Publisher Resources

ISBN: 9781785881985