PDF Version Available
This document is also available in PDF format: greplab.pdf
The PDF version includes bookmarks for easy navigation and is optimized for printing.
Accessibility Notice
This document is also available in HTML format at:
https://aholdengouveia.name/LinuxAdmin/labexcercises/greplab.html
The HTML version provides enhanced accessibility features including keyboard navigation, screen reader support, responsive design, dark mode support, and high contrast options.
Objectives:
- The objective of this lab is to introduce students to grep, a fundamental Linux command-line tool for searching and filtering text using pattern matching and regular expressions. Through hands-on exercises, students will learn to construct effective search patterns for finding specific information in files, including working with literal strings, character classes, anchors, and negation—essential skills for log analysis, data extraction, and system troubleshooting.
Complete the following problems
References, a video and some notes are available at my website
Please include the command, a screenshot showing it works as intended, cite all sources you used, and give a short explanation of how the command works and why.
- Print all lines containing the string Lane
- Print all lines where the person's first name starts with H
- Print all lines ending in three zeros (000)
- Print all lines that don't contain 408
- Print all lines where birthdays are in the year 1935 (be careful of the date format! it's MM/DD/YY)
- Print all lines where the phone number is in an area code that starts with an 8
- Print all lines containing an uppercase letter, followed by 4 lowercase letters, a space and one uppercase letter.
- Print lines where the address begins with a two or three digit number (so this would be 12 main st or 123 main street but not 1234 main street).
- Print lines where the person lives in Mass or Illinois
- Print lines containing the addresses that aren't on a street (You might see St as shorthand for street)
Deliverables
A text document with the grep statements used to get each result. Clearly labeled so I can see which answer goes to which question.
Please include the command, a screenshot that includes the command and a few results showing it works as intended, cite all sources you used, and give a short explanation of how the command works and why. Make sure everything is in your own words. Think of the explanation as you trying to walk someone through how to use grep when they haven't heard of it before.