grep
TextPackage: grep
Searches for a pattern in files or in what is piped to it, and returns the line — or with -q only an exit status, which makes it a test in a script. The pattern is a regular expression unless -F.
What its options do in the lessons
From the same glossary the lessons render under their commands, so the two cannot disagree.
grep -q- Prints nothing: the answer is the exit status, 0 if the pattern was found and 1 if it was not. This is the form that makes
grepusable in anif, and the only one that means anything in a script. grep -F- Takes the pattern literally instead of reading it as a regular expression. The
.in an address or a version number then stops matching any character at all. grep -x- Requires the whole line to match, not part of one. Without it, looking for
max_workers = 4also finds# max_workers = 4— a commented-out setting the script will take for an applied one. grep -i- Ignores case.
grep -n- Prefixes each result with its line number.
grep -c- Counts matching lines instead of printing them. Answers the question of how many, without scrolling a file of several thousand lines.
grep -E- Extended regular expressions:
|,+,?and parentheses without escaping them. grep -C- Prints N lines of context around each match.
grep -r- Descends into the subdirectories of the given path. This searches file *contents*, where
find -namesearches their names.
Lessons that teach it
- Where a package puts its filesYour first server
- Finding filesLinux Fundamentals
- Redirection and pipesLinux Fundamentals
- Reading file contentsLinux Fundamentals
- Reading the access log: what one line already provesHosting a web application with Nginx
- Reading the error log: why the 502 happenedHosting a web application with Nginx
- Ninety days, and nothing will warn youHosting a web application with Nginx
- Which server block answers, and why the wrong site sometimes doesHosting a web application with Nginx
- The limits that refuse: 413 and 504Hosting a web application with Nginx
- Creating a site, then putting a Node.js application on itISPConfig: hosting several sites on one server
- What the panel limits, and what its backups do not coverISPConfig: hosting several sites on one server
- A script you can run twiceBash scripting for administrators
- AppArmor: the refusal permissions do not explainFirewall and hardening
- Hardening the SSH daemon without locking yourself outFirewall and hardening
- What the application asks, and why dig answers a different questionDNS: pointing a domain at your server
- A container with no memory limit, and the process the kernel kills insteadDocker: containers for hosting a Node application
- shared_buffers and work_mem, without the folkloreAdministering PostgreSQL: access, connections and growth
