Bash Patterns and Regular Expressions
2h 2mAdvanced2019-06-06
Authors

Grant McWilliams
Consultant, Speaker, Writer, Professor, Developer
Course details
Pattern matching allows you to create a script that can act on pieces of data if it matches a specific pattern. This makes it possible to script automation into a system process. In this course, learn how to use pattern matching in a Bash script using globs, extended globs, brace expansion, and regular expressions (regex). Throughout this course, Grant McWilliams covers the differences between basic and extended regexes and delves into using extended regexes in bash conditional statements, grep, sed, and AWK.
Learning objectives
What are globs and extended globs?
How locale affects searches
Making extended globs persistent
Comparing extended globs with regular expressions (regexes)
Using brace expansion for patterns
Working with extended regexes
Using sed
Regexes in AWK
Learning objectives
What are globs and extended globs?
How locale affects searches
Making extended globs persistent
Comparing extended globs with regular expressions (regexes)
Using brace expansion for patterns
Working with extended regexes
Using sed
Regexes in AWK
Skills covered
BashIT AutomationNetwork and System AdministrationOpen SourceDeep Dive (X:Y)
Concepts
0. Introduction
- 01 - Use Bash to pull data in seconds
- 02 - What you should know
1. Shell Globs
- 03 - What are globs
- 04 - Shell expansion order
- 05 - Wildcards
- 06 - Character sets
- 07 - The effect of locale on searches
- 08 - Character classes
- 09 - Shell globbing options
2. Shell Extended Globbing
- 10 - What are extended globs
- 11 - Why you should use extended globs
- 12 - Make extended globs persistent
- 13 - Getting started with extended globs
- 14 - Pattern matching with extended globs
- 15 - Using extended globs with commands
- 16 - Comparing extended globs with regular expressions
3. Shell Brace Expansion
- 17 - What is brace expansion
- 18 - Using brace expansion for patterns
4. Introduction to Regular Expressions
- 19 - What are regular expressions
- 20 - Why aren't regexes consistent
- 21 - Basic vs. Extended Regular Expressions
- 22 - Regex support in command line tools
- 23 - Matching characters and words
- 24 - Specifying occurrences
- 25 - Alternation and grouping
- 26 - Back references and subexpressions
5. Use Bash Extended Regexes
- 27 - Regexes in if conditionals
- 28 - Using BASH REMATCH
- 29 - Challenge - Regex to find credit card numbers
- 30 - Solution - Regex to find credit card numbers
6. Grep EREs and PCREs
- 31 - Using regular expressions with grep
- 32 - Perl compatible regexes with grep
- 33 - Performance optimizing grep searches
- 34 - Challenge - Create a regex to find telephone numbers
- 35 - Solution - Create a regex to find telephone numbers
7. Use sed Regexes
- 36 - Using sed
- 37 - Using extended regexes in sed
- 38 - Challenge - Create a regex to find IPv4 addresses
- 39 - Solution - Create a regex to find IPv4 addresses
8. Use AWK Extended Regexes
- 40 - Using regexes in AWK
- 41 - Pattern matching differences in AWK
Conclusion
- 42 - Next steps
Related courses
- Azure DevOps: Continuous Delivery with YAML Pipelines (2020)
- Linux: Bash Shell and Scripts
- Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation
- Learning Bash Scripting
- Learning Bash Scripting (2022)
- Troubleshooting and Debugging Bash
- Linux System Engineer: Bash Shell Scripting for Automation
- Ubuntu Linux: Essential Commands and System Administration
Related learn paths
- Prepare for the Designing and Implementing Microsoft DevOps Solutions (AZ-400) Exam
- Ubuntu Linux Professional Certificate
- Explore a Career in Computer Forensics
- Penetration Testing Professional Certificate
- Become a Penetration Tester
- Prepare for the CompTIA PenTest+ (PT0-002) Certification Exam
- Prepare for the AWS Certified Security - Specialty (SCS-C02) Certification
- Prepare for the CompTIA PenTest+ (PT0-001) Exam