- Lab
- A Cloud Guru
Working with Basic Regular Expressions
Each Linux system administrator needs to have a basic understanding of Regular Expressions, and how to use them. This learning activity will provide you with the chance to practice using some of the more common regular expressions, and utilizing output redirection to create new files.
Path Info
Table of Contents
-
Challenge
Use regular expressions to locate information on http services.
Create a file called http-services.txt in the cloud_user's home directory that contains the values from /etc/services containing 'http' at the beginning of each line, but not containing an 'x' at the end.
This can be accomplished via the following command:
grep ^http[^x] /etc/services > http-services.txt
-
Challenge
Use regular expressions to find port information for LDAP services.
Look for everything that begins with 'ldap' within
/etc/services
where the fifth character can be any alphanumeric character and the sixth character is not the letter 'a'. The results from this search should be placed in a new file in thecloud_user
's home directory calledlpic1-ldap.txt
.This can be accomplished with the following command:
grep ^ldap.[^a] /etc/services > lpic1-ldap.txt
-
Challenge
Create a new file based off of http-services.txt.
Finally, remove any value from http-services.txt containing the word 'service' at the END of the string and concatenate those values to a new file in the cloud_user's home directory called http-updated.txt
This can be accomplished with the following command:
grep -v service$ http-services.txt > http-updated.txt
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.