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:

  1. Write a grep command to find all the IP addresses mentioned in the /var/log/auth.log file. 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 -o flag to grep/egrep. Submit the full grep command you used for this part.
  2. 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 digits d764.
  3. 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 rename command to insert -v1.1 between the name of the file and the extension. So for example, build.sh should become build-v1.1.sh. For this part, you should find the md5sum of the file names by doing ls | md5sum. The sum starts with 62da.

 

Submitting

Submit the answers to the questions in the assignment in Canvas.