Homework assignment HW13
Homework log
Remember to create a new post with a new topic “HW13” in your homework log channel on Microsoft Teams. Make a reply to that topic whenever do some work on this assignment. You can also post questions there. Your posts should provide evidence that you spent several hours doing meaningful work.
Objectives
This assignment covers the use of the Unix tools find and grep, and the utility ripgrep (a faster and more developer-friendly version of grep). You will learn how to use these tools to search for files and text in files, and how to use regular expressions to perform more complex searches.
Minimal knowledge and experience to acquire include the following:
- Use the
findcommand to search for files matching a given name or pattern e.g.find . -name "*.txt"to find all text files in the current directory and its subdirectories. - Use the
findcommand to search for directories matching a given name or pattern e.g.find . -type d -name "src"to find all directories namedsrcin the current directory and its subdirectories. - Use the
grepcommand to search for text in files e.g.grep "TODO" *.pyto find all occurrences of the string “TODO” in Python files in the current directory. - Use the
ripgrepcommand to search for text in files e.g.rg "TODO" -t pyto find all occurrences of the string “TODO” in Python files in the current directory and subdirectories recursively. - Use regular expressions with
grepandripgrepto perform more complex searches e.g.grep -E "TODO|FIXME" *.pyto find all occurrences of the strings “TODO” or “FIXME” in Python files in the current directory.
PB version
The Professor Braught version is available as:
- 13-A-NavigatingCode.docx You are free to follow this version closely if desired, or use it as a loose guide to your activities.
Likely quiz questions
Give Linux terminal commands that perform the following actions:
- Find all files in the current directory and its subdirectories that have the extension
.md. - Find all directories in the current directory and its subdirectories that have the name
src. - Search for the string “my_function” in all Java files in the current directory and its subdirectories.
- Search for the strings of the form “date 03-17-2026” in all Python files in the current directory and its subdirectories, where the date is in the format
MM-DD-YYYYand the year is 2026. (Hint: Use a regular expression to match the date format. Impossible dates like 45-99-2026 are acceptable for this exercise.)