(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. (Global Regular Expression and Print) A Unix pattern matching utility. (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 definition A program which selects lines in a file which match a given pattern. 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.