InterviewSolution
Saved Bookmarks
| 1. |
Explain the command used to count every occurrence of the term “warn” in all the files appearing under the current directory, and its subdirectories, recursively? |
|
Answer» To list every occurrence of the TERM “warn” on a separate LINE, run grep -o warn <path>. Adding the r flag to the command makes recursive search for every file under the given path, and the I flag ensures that matches in BINARY files are ignored. In ADDITION, the w flag can be included to match the exact term only, and IGNORE superstrings such as “warnings”, and to make the search case-insensitive, the i flag can be added. % grep -iworI warn | wc -l 12 |
|