Intermediate Commands
The following sections describe the most essential intermediate Unix commands beyond the basics that you saw earlier in this chapter. There are many more commands where these come from; check out Appendix A for a large list of commands on your system.
grep
grep
prints the lines from a file or input stream that match an expression. For example, if you want to print the lines in the /etc/passwd
file that contain the text root
, use this command:
grep root /etc/passwd
The grep
command is extraordinarily handy when operating on multiple files at once, because it prints the filename in addition to the matching line when in this multiple-file mode. For example, if you want to check on every file in /etc
that contains root
, you could ...
Get How Linux Works now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.