Finding Things
Find text inside files and find files anywhere.
Updated
Finding Text
- Finding Text: grep (Apprentice): grep prints every line that contains a word or phrase, in one file, in many files or in a whole folder, and its options ignore capitals, number the lines, list only the files that match, count the matches or show the lines that don't match.
- Patterns: Regular Expressions for grep (Journeyman): A regular expression describes the shape of the text you want instead of the exact words, so grep can find every phone number or every date in a file; this lesson builds patterns from . and [ ], ^ and $, * and, with grep -E, + and |.
Finding Files
- Finding Files: find (Apprentice): find searches a folder and every folder inside it for files by name, type, size or age, and with -exec it runs a command on each file it finds, best tried with echo first so you see what would happen.
Exercise: The Archive Detective
- Exercise: The Archive Detective (Apprentice): Solve a small mystery in the town archive by searching two weeks of door logs with grep and a regular expression, tracking down a locker, a hidden file and a big scan with find, and clearing out leftover files with find -exec, while a check script tells you which answers are right.