



The inclusion of the file names in the output data can be suppressed by using the -h option as follows: You will see result for 192.168.1.5 on a separate line preceded by the name of the file (such as /etc/ppp/options) in which it was found. read all files under each directory for a string “192.168.1.5” Use grep recursively: You can search recursively i.e. You can force grep to ignore word case i.e match boo, Boo, BOO and all other combination with the -i option: Use grep command to search a file as follows: Search /etc/passwd file for boo user, enter:įoo:x:1000:1000:foo,:/home/foo:/bin/ksh The name, “grep”, derives from the command used to perform a similar operation, using the Unix/Linux text editor ed: g/re/p grep is considered as one of the most useful commands on Unix and other Linux operating systems. Use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines. By default, grep displays the matching lines. The grep command is used to search text or searches the given file for lines containing a match to the given strings or words. Grep “String” -r *.txt : will do the same things as above except that it will only look at files with the. Grep “String” -r * : will search for “String” in all the subfolders and files recursively and will not discriminated between file extensions. Grep’s official creation date is given as March 3, 1973, in the Manual for Unix Version 4. In ed, the command g/re/p would print all lines matching a previously defined pattern. Grep was created by Ken Thompson as a standalone application adapted from the regular expression parser he had written for ed (which he also created). Its name comes from the ed command g/re/p (globally search a regular expression and print), which has the same effect: doing a global search with the regular expression and printing all matching lines. Grep was originally developed for the Unix operating system, but is available today for all Unix-like systems. Grep is a command-line utility for searching plain-text data sets for lines matching a regular expression.
