

This will help user to go the line when user open the file in vi editer to know nearby logs.

Following picture show the example where we can see error (small letter) appeared two time in the log file an Error (with captil ‘E’) appeared 22 time in the event-log file. count option is case sensitive, be sure about the actual search string.

This is useful when we want to know how many time one particular error happen in the log file. grep with count: grep with option -c search and provide the number of count for a text or string appeared in the file.For example if you want to search error in a file, you can put error or Error in search text will ingore and provide all related matching lines. grep with ingore case: grep with option -i search for the given text and igore the upper/lower case.-o : Print only the matched parts of a matching line, with each such part on a separate output line.-E : Treats pattern as an extended regular expression.-f file : Takes patterns from file, one per line.-e exp : Specifies expression with this option.-v : This prints out all the lines that do not matches the pattern.This will print a wall of console output to the terminal, something that we can search using grep. -n : Display the matched lines and their line numbers Open a terminal and run the dmesg command as sudo.-i : Ignores upper/lower case for matching.-h : Display the matched lines, but do not display the filenames.-c : This prints a count of the lines that match the pattern.
#Grep usage in linux windows
grep does not work in the Windows environment.grep user requires read/write permissions to access the desired files and directories.grep requires access to a terminal/command line.egrep, and fgrep are other similar tools.The grep command is handy tool for searching known text or string through large log files.When grep finds a match, it prints the line with the result.grep stands for global regular expression and print.In this blog posts, Let us dicuss what are different ways we can used grep on a Linux system. It is one of the most useful commands on Linux systems for Developers and testers for debugging the system logs. In other words, we can say that grep command search provides the lines containing a match strings or words in the given file. Grep originated from a UNIX text editor that provided a command sequence g/re/p for global/regular expression/print.Grep is an essential command utility used in Linux and Unix environments to search text and strings in a given file. (The quote marks around the string argument in this example are optional, but quotes are required where the argument is a phrase or contains a blank.) The period (dot) indicates that any character may precede the string hood and the asterisk (*) says that any number of the "any characters" indicated by the dot can precede the string.

Would search the essay1 file and display every line containing a word with the string hood. Grep allows the string argument to be specified as a regular expression, which is a way of specifying a string that allows certain metacharacters (special keyboard characters such as the period) to stand for other characters or to further define the way the pattern-matching should work. The output from grep can be the input (perhaps using the UNIX pipe symbol) for a replacement command. grep can also be used as the first step in an automatic procedure to search and replace a word or phrase. If you are not sure exactly what the effect might be of making the replacement, grep identifies the lines and you can decide what further action to take for each occurrence. (In the above command, we could have specified additional files besides homepage.htm.) It can also be used to search for word or string occurrences that need to be replaced. Grep can be used simply as a way of searching, especially through multiple files. The result would be to display any line in the homepage.htm file that includes the character string html. homepage.htm specifies the file to search. Html specifies the character string to search for on each line. For example, a UNIX system user can enter on a command line: Grep, a UNIX command and also a utility available for Windows and other operating systems, is used to search one or more files for a given character string or pattern and, if desired, replace the character string with another one.
