hostgrep1
Print lines matching hostlist
Usage
hostgrep [OPTION] ...
HOSTLIST
[FILE] ...
Overview
Search the files for lines matching the given hostlist. If no files are given, search the standard input.
For each line, the program tries to find all hostnames and hostlists. Hostlists are then expanded to hostnames. The set of hostnames in a line is then compared to the set of hostnames given by the HOSTLIST on the command line. By default, the line is printed if any hostname from the HOSTLIST is found in the line.
Options
-
--all -
Print a line if all hostnames in the given HOSTLIST is found in the line.
-
--any -
Print a line if any hostname in the given HOSTLIST is found in the line (the default).
-
-h, --no-filename -
Do not show the filename in front of matching line. This is the default if at most one FILE is given.
-
-H, --with-filename -
Show the filename in front of matching lines. This is the default if two or more FILES are given.
-
-v, --invert-match -
Invert the sense of matching, to select non-matching lines.
-
-n, --line-number -
Show line number before match.
-
--restrict=REGEXP -
Restrict host matching to the part of the line that is matched as group 1 by this regexp.
Examples
Search for lines in an accounting file where any of the three hosts is present (as a hostname or part of a hostlist):
|
|
|---|---|
Search for lines in the accounting files where all of the three hosts are present (as a hostname or part of a hostlist). Do not show filenames:
|
|
Search for lines on stdin where nodes in n[1-8] are mentioned in the part of the line that comes before the first colon:
|
|