grepc(1)

๐Ÿ“ฆ
version 6.20 ยท 4 versions
, in arch rolling, nixpkgs unstable

โœจ grepc(1) โ€” bestie edition โœจ

okay so grepc is literally that girl for digging through source code ๐Ÿ’… she finds declarations, definitions, and uses of whatever you're looking for. this is the grepc manual, straight from the General Commands Manual shelf, and I'm gonna walk you through it like we're texting at 2am ๐Ÿฆ‹


๐ŸŒธ NAME ๐ŸŒธ

grepc โ€” find declarations, definitions, and uses in source code

no cap, that's the whole job. three vibes: decl, def, use. she does all three. ๐Ÿ‘‘

๐ŸŽ€ SYNOPSIS ๐ŸŽ€

grepc [option ...] pattern [file ...]

โœจ DESCRIPTION โœจ

grepc(1) goes hunting for declarations, definitions, and/or uses of pattern inside each source file you hand her. she's thorough like that ๐Ÿ’–

pattern is a PCRE pattern. normally it's standing in for an identifier, and in most cases the program implicitly adds word boundaries around it โ€” so you don't have to be all fussy about it, she's got you ๐Ÿซถ

if you don't give her any file, she reads standard input. otherwise she reads every file you list, and if you point her at directories she searches them recursively โ€” but note: she does not follow symbolic links. periodt. ๐Ÿšซ๐Ÿ”—


๐Ÿ’… OPTIONS ๐Ÿ’…

  • -A n โ€” print n lines of trailing context after a match. afterparty content ๐ŸŒˆ
  • -B n โ€” print n lines of leading context before a match. the pregame โœจ
  • -C n โ€” print n lines of context surrounding a match. both sides, balanced queen โš–๏ธ
  • -c โ€” don't print the matches themselves, just print a count of them instead. receipts only ๐Ÿงพ
  • -h โ€” suppress prefixing file names on output. no name-dropping ๐Ÿ™ˆ
  • -i โ€” ignore case distinctions in pattern. she's not gonna judge your caps lock ๐Ÿ’€
  • -l โ€” suppress normal output; instead print the name of each input file that would have produced output. and heads up: each file is only printed once, no repeats bestie ๐Ÿ‘‘
  • -m n โ€” stop processing after finding n matches. she knows when to log off ๐ŸŒ™
  • -n โ€” prefix each line of output with the 1-based line number within its input file. so you can find your way back ๐Ÿ“
  • -t type โ€” restrict the search to a specific type of code. you can pass this option multiple times to search various types of code. the acceptable values depend on the driver used for the language โ€” check grepc_c(1), which is the default driver. pick your fighter ๐ŸฅŠ

๐Ÿ˜ญ CAVEATS ๐Ÿ˜ญ

๐Ÿ’€ Crashes

soโ€ฆ in some cases, internal calls to pcre2grep(1) may fail after consuming too much resources. yeah. she ate too hard and passed out ๐Ÿ˜ญ

to solve that, use -t to restrict the types of code of your search. that's the fix, bestie.

๐Ÿซฃ Seekable files

files given on the command line must be seekable and able to be opened twice. if you need to read a non-seekable file, just redirect it to standard input instead. she needs her space to work, ok?? ๐Ÿงš


๐ŸŒŸ EXAMPLES ๐ŸŒŸ

alx@devuan:/usr/lib/gcc$ grepc -n alignof .;
./x86_64-linux-gnu/15/include/stdalign.h:33:#define alignof _Alignof

look at her go. found it, numbered it, slayed it. ๐Ÿ”ฅ


๐Ÿ”— SEE ALSO ๐Ÿ”—

grepc_c(1), pcre2grep(1), pcre2syntax(3), pcre2pattern(3)


and that's the whole page, babes ๐Ÿ’– this lil masterpiece is from Linux man-pages 6.20, dated 2025-11-09, and it is the grepc(1) manual โ€” go forth and grep, you main character ๐ŸŒˆ๐Ÿ‘‘๐Ÿ’œ

๐Ÿ“ฆ where this page comes from