How To Make Good Use Of ‘grep’ Command
Basic Overview of ‘grep’
The fourth command is different. The first parameter, ‘-r’, tells grep to search through a directory recursively. The directory, in this case, is the current one (/etc), denoted by the ‘.’. The next parameter, ‘-s’, tells grep to avoid reporting any errors, such as “Permission Denied” errors, to the output, so as not to pollute the output with errors. So the fourth grep command lists all of the occurrences of “unix” in all of the files in /etc and its subdirectories, where any errors are simply ignored.
All lines containing at least one of these patterns will be shown on the terminal output.
Something A Little More Advanced
Two examples using the kernel log (/var/log/kern.log). Have a look at this picture:
You can even make use of pipes for more complicated searches and filtering using grep. It is well worth the time to learn more about this excellent command, especially some of its advanced features.