![]() Let’s move ahead, and this time, we will find the files with a specific word or string of words. Use Grep to Find All Files Containing a Matching Text (grep -l) So, we should keep casing in mind when we are searching for text. Let’s run the same command, but the word that we will search is “ kali” instead of “ Kali”. ![]() There are a total of 11 occurrences of the word Kali in the nf file. Still, the grep command has been able to find the required word.Īs soon as we hit Enter, we get the response. ![]() 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 following command: grep -c "Kali" nf We will use the -c parameter to find the word “ Kali” in the nf file. We can even find the number of occurrences a word appears in a file. Using Grep to Count Occurrences (grep -c) Still, the grep command has been able to find the required word. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |