About
The classic pattern matcher. It reads lines, prints those containing a match, and understands regular expressions. It also recurses, counts, inverts and colourises, and it is the backbone of countless pipelines.
Install it
pkg install grep
Run this inside Termux. If the package is already present, pkg will say so and
do nothing.
Commands worth knowing
6 of the invocations you will actually reach for. Tap the copy button to put one on your clipboard.
grep -i error app.log Print every log line containing the word, ignoring case. grep -rn "TODO" src/ Walk a directory and show matching lines with path and line number. grep -c "GET" access.log Count matching lines and print only the total. grep -v "^#" config.ini Invert the match. Everything not starting with a comment marker is shown. grep -E "warn|error" app.log Use extended regular expressions, so alternation works without escaping. grep -A2 -B2 "panic" app.log Include two lines of context before and after each match. Worked example
Run grep -rn "TODO" src/ and this is what you should see.
$ grep -rn "TODO" src/
src/main.ts:14:// TODO: handle empty input
src/util.ts:3:// TODO: cache results
src/api.ts:52:// TODO: retry on timeout Developed by
GNU Project .