BOOL(1)

NAME
bool - print context matching a boolean expression

SYNOPSIS
bool [options] EXPRESSION [FILE...]

DESCRIPTION

Bool searches the named input FILEs (or standard input if the file name - is given) for the context of each identifier in the given EXPRESSION. If the input is HTML formatted, it is parsed before being queried.

By default, bool prints the first occurence in its context for each identifier if the EXPRESSION is true. This consists of up to 60 characters preceding and following the identifier, until a beginning or end of paragraph is reached.

OPTIONS

-C NUM, --context=NUM
    Print NUM characters (default 60) of output context for each keyword.

-c, --count
    Suppress normal output; instead print a count of matching keywords for each input file.

-D NUM, --distance=NUM
    Find patterns separated by NUM words (default 10) when using the NEAR operator.

-F, --fixed-string
    Interpret EXPRESSION as a fixed string instead of a boolean expression.

-H, --with-filename
    Print the filename for each match.

-h, --no-filename
    Suppress the prefixing of filenames on output when multiple files are searched.

--help
    Output a brief help message.

-i, --ignore-case
    Ignore case distinctions in both the EXPRESSION and the input files.

-K, --with-keyword
    Print the keyword for each match.

-k, --no-keyword
    Suppress the prefixing of keywords on output.

-L, --files-without-match
    Suppress normal output; instead print the name of each input file from which no output would normally have been printed. The scanning will stop on the first match.

-l, --files-with-matches
    Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match.

-O NUM, --occurences=NUM
    Print NUM lines (default 1) of context for each keyword. No output is printed if the boolean expression evaluates to false.

-q, --quiet, --silent
    Quiet; suppress normal output.

-V, --version
    Print the version number of grep to standard error. This version number should be included in all bug reports (see below).

BOOLEAN EXPRESSIONS

A boolean expression is composed of operands separated by operators. The precedence of operators is evaluated from left to right.

Operands can be another boolean expression isolated between parentheses or an identifier. The latter is expressed as a sequence of characters delimited by spaces or enclosed in quotes. Some characters can be escaped using the backslash ('\'), other characters can be specified as SGML entities.

An operand must return a truth value. For a parenthesized expression, each operator within the expression is evaluated as described below. For an identifier, the operand is true if there are one or more occurences of the sequence of characters in the input. Otherwise, the operand is false.

Operators are symbols denoting the logic to be performed. The AND operator returns true if the operands on either side of the symbol are true, otherwise the expression is considered false. The OR operator returns true if either operand is true. The NOT operator returns true if the left operand is true and the right operand is false.

The NEAR operator, though not boolean, returns true if the operands on either side of the operator are within a specified number of words from each other. For example, the words "boolean" and "either" are separated by 6 words in the previous sentence. If the distance specified on the command-line is 10, the expression is true.

DIAGNOSTICS
Bool exits 0 when the pattern is found in any of the files, otherwise 1.

AUTHOR
Marc Tardif <intmktg@cam.org>