Still, the grep command has been able to find the required word. Notice that even though we had specified the word kali in lowercase, the nf file included all words that were starting with an uppercase. To do this, we need to use the -i parameter. Using Grep and Ignoring Case (grep -i)įirst, we will perform a case insensitive search, which means that it will find the searched word in any casing, be it upper, lower, or a mix of both. Note: If we need to verify that the file has been copied, we can list the files in the current directory using the ls command. Let’s scroll up and view some of the key parameters we will use in this tutorial. To view the parameters available with the grep command, we need to use the –help parameter: grep – help However, before moving forward, let’s look at the grep command and its parameter by viewing its detailed help. Going forward, we will see some of its different use cases. Acting as a non-root sudo user to ensure a secure environmentĪs we said before, the grep command is used for finding words or patterns across files.Mixing the Grep Command with Other Commands (somecommand | grep pattern).
![use grep to find word in multiple files use grep to find word in multiple files](https://i.ytimg.com/vi/N05sWPgj-44/maxresdefault.jpg)
Grep Recursively Through Subdirectories (grep -r).Use Grep and Display Lines Before/After Matching Pattern (grep -B or grep -A).Use Grep and Show Only Lines that Don’t Contain Matching Text (grep -v).Use Grep and Show Only Match and Corresponding Line Numbers (grep -n -o).Use Grep and Show Lines and Line Numbers (grep -n).Use Grep and Show Only Matching Text/Pattern (grep -o).Use Grep to Find All Files Containing a Matching Text (grep -l).Using Grep to Count Occurrences (grep -c).