Here we’re going to Search text in file using grep in Unix?
Searching for text or string in file or folders using grep command, this command will be very much handy when searching for text in file using grep.
grep is one of the powerful command used for searching in files or folder with the search pattern.
Lets see how to search for text or string in files or folders using grep command
grep [options] "search pattern"[regex] [filename/foldername]
Note: use double quotes for your search string
Options : (Below are frequently used options with grep command)
-i Ignores case
-n Print the line number
-c Count of matched pattern (Will not print the search line, rather it just prints the count)
-r Will search folders for matching text.
-v non-matched lines are printed
Try for yourself:
1) Search for any string and print count
hint: use -c
2) Search entire folder for match pattern with , (This is special symbol)
3) Search string by ignoring the case and also search for multiple string in a file
hint: use -v and in search string you need to split using | for multiple search string.
Subscribe to our channel for more videos : https://bit.ly/aryanz-youtube