aboutsummaryrefslogtreecommitdiffstats
path: root/man/man1/grepc.1
blob: 7fea55ca85206c22f860f70c3746425c5e951fe4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH grepc 1 (date) "Linux man-pages (unreleased)"
.SH NAME
grepc \- find declarations, definitions, and uses in source code
.SH SYNOPSIS
.B grepc
.RI [ option\~ .\|.\|.\&]
.I pattern
.RI [ file\~ .\|.\|.\&]
.SH DESCRIPTION
.BR grepc (1)
searches for declarations, definitions, and/or uses of
.I pattern
in each source
.IR file .
.P
.I pattern
is a PCRE pattern.
It normally represents an identifier,
and word boundaries are implicitly added to it in most cases.
.P
If no
.I file
is given,
this program reads standard input.
Otherwise,
it reads all files specified,
and searches under any specified directories, recursively,
without following symbolic links.
.SH OPTIONS
.TP
.BI \-A \~n
Print
.I n
lines of trailing context after a match.
.TP
.BI \-B \~n
Print
.I n
lines of leading context before a match.
.TP
.BI \-C \~n
Print
.I n
lines of context surrounding a match.
.TP
.B \-c
Do not print matches,
and instead print a count of them.
.TP
.B \-h
Suppress the prefixing of file names on output.
.TP
.B \-i
Ignore case distinctions in
.IR pattern .
.TP
.B \-l
Suppress normal output;
instead print the name of each input file
from which output would normally have been printed.
Each file is only printed once.
.TP
.BI \-m \~n
Stop processing after finding
.I n
matches.
.TP
.B \-n
Prefix each line of output with the
1-based line number within its input file.
.TP
.BI \-t \~type
Restrict the search to a specific
.I type
of code.
This option can be passed multiple times
to search for various types of code.
The acceptable values depend on the driver used for the language.
See
.BR grepc_c (1),
which is the default driver.
.SH CAVEATS
.SS Crashes
In some cases,
internal calls to
.BR pcre2grep (1)
may fail after consuming too much resources.
To solve that,
use
.B \-t
to restrict the types of code of your search.
.SS Seekable files
Files specified in the command line
must be seekable and able to be opened twice.
If you need to read a non-seekable file,
redirect it to the standard input.
.SH EXAMPLES
.EX
.RB alx@devuan:/usr/lib/gcc$ " grepc -n alignof ." ;
\&./x86_64\-linux\-gnu/15/include/stdalign.h:33:#define alignof _Alignof
.EE
.SH SEE ALSO
.BR grepc_c (1),
.BR pcre2grep (1),
.BR pcre2syntax (3),
.BR pcre2pattern (3)