grep¶
One line: grep prints the lines that match a pattern, but GNU grep on Linux and BSD grep on a Mac disagree about which options exist and what some patterns mean. A command copied from a Linux book can be an error on a Mac, or quietly match something else.
| Lesson | Level | What it settles |
|---|---|---|
Counting with ls, grep and wc -l |
101 | The book's ls -l count, grep -c, the spaces a Mac's wc adds, and an unquoted alma* in bash, zsh and fish |
cat into grep is one process too many |
101 | What grep loses when it reads cat's stream instead of file names, < file in the three shells, and the line cat glues together |
| The everyday options | 101 | -i -v -w -n -o -c -l -h -r -E -e on both machines, a pattern that starts with -, and ** instead of -r |
| grep exits 0, 1 or 2 | 101 | Found, not found and error; -q and -s; if, case, set -e, and fish's switch |
| GNU grep and BSD grep | 201 | What a Linux book's grep line keeps on a Mac, and what it loses: -P, \d, -Z, -r and symlinks |
Planned¶
Rough order, not a promise:
- Basic, extended and Perl regular expressions:
grep,grep -Eandgrep -Pside by side, which characters are special in each, andgrep -Ffor none