Lab 10: Regular Expression Exercise
Objective
To get experience working with regular expressions
Task
For this lab you will do three things involving regular expressions:
- Write a grep command to find all the IP addresses mentioned in the
/var/log/auth.logfile. To do this, search the file using a regex for an IP address, which is 4 sets of 1-3 digits, separated by.characters. In order to get just the IP addresses to be printed, include the-oflag to grep/egrep. Submit the full grep command you used for this part. - Anonymize the file emails.txt to replace all email
addresses found in the file with the text
[email redacted]. Be sure to note that email addresses can contain.characters, but cannot end with them! Submit the md5sum of the anonymized emails.txt file for this part of the lab. The sum begins with the digitsd764. - Rename a set of files in the files.tar.gz
tarball. This contains a bunch of empty files. You should change the names
using a regex and the
renamecommand to insert-v1.1between the name of the file and the extension. So for example,build.shshould becomebuild-v1.1.sh. For this part, you should find the md5sum of the file names by doingls | md5sum. The sum starts with62da.
Submitting
Submit the answers to the questions in the assignment in Canvas.