we can search every file in this folder and it returns each line in the word file it found this matches in a zip file it found. Example #3Įxplanation: Now if we want to search every file in this current folder let’s see what we have here is five different files if we want to grep “is”. Example #2Įxplanation: We can search multiple files we can do let’s say grip, in this case, our string is just a number eight and we’ll search in two files file1 and file2 so we can just add as many filenames on here as we want and it’ll search for this string inside of each of these files. So, in this case, it found one line where there was a match and it returned hello world that’s the line. Output: It will show a file or directory of the name hello.Įxplanation: in this case, look for a world with file name, hello, and then it will return every line where there’s a match every line where it finds this pattern or this word in this file.
Here are the following examples mention below Example #1 i => it will ignores case for matching Examples of GREP Command in Linux o => Print only the matched parts of a matching line with each such part on a separate output line. c => it prints only a count of the lines that match a pattern E => Treats pattern as an extended regular expression.
f file => it takes patterns from a file, one per line