|
The grep command is so beloved by Linux users that it has its own t-shirts. The grep command finds files that have specified contents and outputs each line that it finds. The general format for the grep command is: grep options pattern files where:
For example, the following is a simple grep command with its output: grep "Mary Poppins" * file1.txt:I like Mary Poppins! file7.txt:Mary Poppins is a great movie. The command looks in all the files in the current directory for the string, Mary Poppins. Lines containing the search string display, with the filename prepended. You can use a path (such as /home/janet) instead of *, to specify a directory and all the files in that directory are searched. The grep command has many options, some of which are shown in Table 7-6.
|
|