Tracking Signs
Concept:
grep — searches for text patterns inside files. Usage: grep "pattern" file.txt. Flags: -i (case-insensitive), -r (recursive through directories), -n (show line numbers). The name stands for Global Regular Expression Print. There's a hacker saying: 'You can't grep dead trees' — meaning digital text is searchable, but paper isn't. That's your superpower.
find — locates files by name, size, or type across directories. Usage: find . -name "*.txt" finds all .txt files from the current directory down.
Terminal:
You've made camp, gathered resources. Now you need to learn to track — find things in the wilderness. 'grep' is your tracker. It hunts for text patterns inside files.
You:
Like searching for footprints?
Terminal:
Exactly. 'grep "water" notes.txt' finds every line mentioning water. Add '-i' and it ignores case — 'Water', 'WATER', 'water' all match. Add '-n' to see line numbers, like GPS coordinates for each find.
You:
What if I don't know which file to look in?
Terminal:
That's where 'find' comes in. It's your aerial scout. 'find . -name "*.txt"' searches from here downward for anything ending in .txt. The dot means 'start from where I'm standing.' It searches every trail, every subdirectory.
You:
So grep looks inside files, and find looks for files themselves?
Terminal:
Now you're thinking like a survivor. There's an old saying: 'You can't grep dead trees.' It means you can search digital text instantly — but paper? You'd have to read every page by hand. That's the advantage of the terminal.
You:
Dead trees... meaning paper. I get it.
Terminal:
There's a server log in this area — something left behind by whoever was here before. Search it for errors. It might tell us what went wrong.
Example Code:
grep "error" server.log
# Line 42: error: connection refused
# Line 89: error: timeout
grep -n "warning" server.log
# 15:warning: disk space low
find . -name "*.log"
# ./logs/server.log
# ./logs/access.log
Your Assignment
Search the file 'server.log' for all lines containing 'ERROR' (case-insensitive).
Bash Console
bash>