1 | CGREP
|
---|
2 |
|
---|
3 | NAME
|
---|
4 | cgrep \- search a file for a piece of context
|
---|
5 |
|
---|
6 | SYNOPSIS
|
---|
7 |
|
---|
8 | cgrep [-mi] [-n -p -/pat] [+n +p +/pat] pattern [ files... ]
|
---|
9 |
|
---|
10 | DESCRIPTION
|
---|
11 |
|
---|
12 | Cgrep takes a chunk of context out of a text file based on a pattern
|
---|
13 | that lies inside the context, and rules for specifying the amount of
|
---|
14 | context. If no rules are specified, then cgrep works just like grep
|
---|
15 | except that it finds only the first occurrence of "pattern".
|
---|
16 |
|
---|
17 | A backward searching rule need not be matched by a forward searching
|
---|
18 | rule, and vice versa, however, no more than one rule "per direction"
|
---|
19 | should be used.
|
---|
20 |
|
---|
21 | Cgrep does not recognize the grep family metacharacters. It matches
|
---|
22 | exactly what it is given. The default input is stdin.
|
---|
23 |
|
---|
24 | When more than one file is searched, the name of the file in which the
|
---|
25 | context is found is enclosed in <> at the top of the text.
|
---|
26 |
|
---|
27 | OPTIONS
|
---|
28 |
|
---|
29 | -n Begin printing 'n' lines before the first occurrence of
|
---|
30 | "pattern". If no 'n' is specified, default is one.
|
---|
31 |
|
---|
32 | -p Begin printing at the beginning of the paragraph
|
---|
33 | containing the first occurrence of "pattern". (assuming
|
---|
34 | that paragraphs are separated by a blank line)
|
---|
35 |
|
---|
36 | -/pat Begin printing at the line containing "pat" nearest
|
---|
37 | before the first occurrence of "pattern".
|
---|
38 |
|
---|
39 | +n Stop printing 'n' lines after the first occurrence of
|
---|
40 | "pattern". If no 'n' is specified, default is one.
|
---|
41 |
|
---|
42 | +p Stop printing at the end of the paragraph containing the
|
---|
43 | first occurrence of "pattern". (i.e. the next blank line)
|
---|
44 |
|
---|
45 | +/pat Stop printing at the first line past "pattern" which
|
---|
46 | contains "pat".
|
---|
47 |
|
---|
48 | -i Ignore case.
|
---|
49 |
|
---|
50 | -m Mail mode. Delete all blank space at the beginning of the
|
---|
51 | lines to be printed and insert "> ". This may be useful
|
---|
52 | from within the editor in replying to mail or news.
|
---|
53 | |
---|
54 |
|
---|
55 | EXAMPLE
|
---|
56 |
|
---|
57 | cgrep -2 +/john harry file1
|
---|
58 |
|
---|
59 | searches file1, and prints starting 2 lines before the first
|
---|
60 | occurrence of "harry" and ending when it finds a line containing "john"
|
---|
61 |
|
---|
62 | cgrep -p +p george file2
|
---|
63 |
|
---|
64 | searches file2 and prints the paragraph containing "george"
|
---|
65 |
|
---|
66 | BUGS
|
---|
67 |
|
---|
68 | When using both -m and -i, use separate flags.
|
---|
69 |
|
---|
70 | Results are unpredictable if multiple rules for searching the same
|
---|
71 | direction are given, though it will probably use the latter.
|
---|
72 |
|
---|
73 | If the pattern is found in the first of multiple files,
|
---|
74 | the filename is not printed at the top.
|
---|
75 |
|
---|
76 | If a backward pattern search is done on a non-existent pattern,
|
---|
77 | the backward search is ignored.
|
---|
78 |
|
---|
79 | Line length is limited to 256 characters.
|
---|
80 |
|
---|
81 | Send all comments, etc to iannucci@sjuvax.UUCP
|
---|