Information AboutGrep |
| CATEGORIES ABOUT GREP | |
| unix software | |
| gnu project software | |
|
grep is a Command Line utility originally written for use with the Unix operating system. The default behaviour of grep takes a Regular Expression on the command line, reads Standard Input or a list of files, and outputs the lines containing matches for the regular expression. The name comes from a command in the Unix text editor Ed that takes the form: :g/''re''/p which means "search globally for lines matching the '''r'''egular '''e'''xpression, and '''p'''rint them". There are various command line switches available when using grep that modify the default behaviour. Variations There are many derivatives of grep, for example Agrep which stands for ''approximate grep'' to facilitate Fuzzy String Searching , Fgrep for fixed pattern searches, and Egrep for searches involving more sophisticated regular expression syntax. fgrep and '''egrep''' are typically the same program as '''grep''', which behaves differently depending on the name by which it is invoked. Tcgrep is a rewrite of grep and uses Perl regular expression syntax. All these variations of grep have been ported to many computer operating systems. Many other commands contain the word "grep." Pgrep , for instance, displays the processes whose names match a regular expression. In Perl , grep is a built-in function, which when provided both a Regular Expression (or a general code block) and a list, it returns the elements of that list matched by the expression. Usage as a conversational verb As the name "grep" neatly fits the grepped his Usenet spool for his name." Compare with '' Google ''. Sometimes ''visual grep'' is used as a term meaning to look through text searching for something, in the manner of the grep program. The word "grep" has also become a synonym for regular expressions themselves. Many text and word processors now employ regular expression search features, which those applications will often refer to as a "grep tool" or "grep mode" in which one creates "grep patterns", causing confusion, especially in non-Unix environments. EXAMPLES
To output all lines not containing the string "foo", use "-v": To output only the names of the matching files, use "-l": To output all matching lines in the given list or files or directories, or recursively into their subdirectories ("." represents the current directory), use "-r": :grep -r foo . grep also can read from standard input: |
|
|