Difference between revisions of "Tutorial9: Regular Expressions"
(→Regular Expressions vs. Filename Expansion) |
(→Regular Expressions vs. Filename Expansion) |
||
Line 58: | Line 58: | ||
<table align="right"><tr valign="top"><td>[[Image:re-1.png|thumb|right|350px|Filename expansion symbols allow the Linux shell to expand filenames as arguments (referred to as “globbing”).]]</td><td>[[Image:re-2.png|thumb|right|250px|Output of the '''ls -lR''' command to display directory structure.]]</td></table>In a previous lesson, you learned that filename expansion symbols allow the Linux shell to expand filenames as arguments (referred to as “globbing”) for file management commands. This is very useful for managing multiple files sharing similar characteristics such as the same file extension. | <table align="right"><tr valign="top"><td>[[Image:re-1.png|thumb|right|350px|Filename expansion symbols allow the Linux shell to expand filenames as arguments (referred to as “globbing”).]]</td><td>[[Image:re-2.png|thumb|right|250px|Output of the '''ls -lR''' command to display directory structure.]]</td></table>In a previous lesson, you learned that filename expansion symbols allow the Linux shell to expand filenames as arguments (referred to as “globbing”) for file management commands. This is very useful for managing multiple files sharing similar characteristics such as the same file extension. | ||
− | + | Filename Expansion symbols are used to search, edit and manipulate text and are used with Linux file management commands such as '''ls''', '''rm''', '''mv''', '''cp''', '''cat''', '''less''' and '''more'''. This can represent text contained in files or text as a result of issuing Linux commands using a pipeline. | |
A '''regular expression''' is a combination of two types of characters: '''literals''' and '''special characters'''. In combination, these characters define a logical pattern. Strings of text can be compared to this pattern to see if they fit the pattern defined by the expression. | A '''regular expression''' is a combination of two types of characters: '''literals''' and '''special characters'''. In combination, these characters define a logical pattern. Strings of text can be compared to this pattern to see if they fit the pattern defined by the expression. |
Revision as of 09:39, 4 July 2020
Contents
USING REGULAR EXPRESSIONS
Main Objectives of this Practice Tutorial
- Explain the purpose of Regular Expressions
- Understand the difference between Regular Expressions and Filename Expansion
- Understand the purpose of Literal (Simple) Regular Expressions
- Understand common symbols for Complex Regular Expressions and their purpose
- Understand command symbols for Extended Regular Expressions and their purpose
- Use various Linux commands that use regular expressions
Tutorial Reference Material
Course Notes |
Linux Command/Shortcut Reference |
YouTube Videos | ||
Course Notes:
|
Regular Expressions
|
Additional Linux Commands that Use Regular Expressions | Brauer Instructional Videos: |
KEY CONCEPTS
A regular expression … is a sequence of characters that define a search pattern.
Usually such patterns are used by string searching algorithms for "find" or "find and replace" operations on strings, or for input validation.
Reference: https://en.wikipedia.org/wiki/Regular_expression
Regular Expressions vs. Filename Expansion
Filename Expansion symbols are used to search, edit and manipulate text and are used with Linux file management commands such as ls, rm, mv, cp, cat, less and more. This can represent text contained in files or text as a result of issuing Linux commands using a pipeline.
A regular expression is a combination of two types of characters: literals and special characters. In combination, these characters define a logical pattern. Strings of text can be compared to this pattern to see if they fit the pattern defined by the expression.
Reference: https://www.whoishostingthis.com/resources/regex/
Literal (Simple) Regular Expressions
x
Complex Regular Expressions
x
Extended Regular Expressions
x
INVESTIGATION 1: SIMPLE & COMPLEX REGULAR EXPRESSIONS
In this section, you will learn how to ...
Perform the Following Steps:
- x
In the next investigation, you will ...
INVESTIGATION 2: EXTENDED REGULAR EXPRESSIONS
In this section, you will learn how to ...
Perform the Following Steps:
- x
In the next investigation, you will ...
INVESTIGATION 3: OTHER COMMANDS THAT USE REGULAR EXPRESSIONS
In this section, you will learn how to ...
Perform the Following Steps:
- x
LINUX PRACTICE QUESTIONS
The purpose of this section is to obtain extra practice to help with quizzes, your midterm, and your final exam.
Here is a link to the MS Word Document of ALL of the questions displayed below but with extra room to answer on the document to simulate a quiz:
https://ict.senecacollege.ca/~murray.saul/uli101/uli101_week9_practice.docx
Your instructor may take-up these questions during class. It is up to the student to attend classes in order to obtain the answers to the following questions. Your instructor will NOT provide these answers in any other form (eg. e-mail, etc).
Review Questions:
- x
- x
- x
- x
- x
- x
- x
- x