Archive for the 'GREP Tools' Category

How can i search for files which contain string A but not string B ?

Pipe the output of grep through grep -v. For example:

grep 'A' file | grep -v 'B'

Why grep ‘foo|bar’ file doesn’t work?

The bar | has no special meaning in BRE (basic regular expressions). Use extended regular expressions (ERE) such as:

grep -E 'foo|bar' file

or

egrep 'foo|bar' file

In GNU grep, you can also force the spcial meaning of | by escaping it. E.g.,

grep 'foo\|bar' file

Is grep an acronym? Does it mean GNU Regular Expression P?

grep originated from ed command: g/re/p where re is a regular expression, g stands for globally, and p stands for print. So one could say grep is an acronym of “Global Regular Expression Print“.

Global Regular Expression Print Tools (grep variants)

Overview
The UNIX grep utility marked the birth of a global regular expression print (GREP) tools. Searching for patterns in text is important operation in a number of domains, including program comprehension and software maintenance, structured text databases, indexing file systems, and searching natural language texts. Such a wide range of uses inspired the development of variations of the original UNIX grep. These variations range from adding new features, to employing faster algorithms, to changing the behaviour of pattern matching and printing.
Continue reading ‘Global Regular Expression Print Tools (grep variants)’