CG(1)
πΈ CG β the manual, but make it a group chat πΈ
okay so bestie, this is cg(1) β manual section 1, the user commands section, and honestly? she's iconic. no preamble needed, let's get into it. π
β¨ NAME β¨
cg β recursively grep for a pattern and store it. that's it, that's the whole job. search the tree, keep the receipts. π«Ά
π¦ SYNOPSIS π¦
like, it's either `<mint>-l</mint>` on its own OR a pattern (maybe with `<mint>-i</mint>`) and maybe some files. pick a lane, she supports both. π
---
# π DESCRIPTION π
okay so here's the tea. `cg` does a search through text files β usually source code, because that's the vibe β **recursively**, hunting for a pattern, and it *stores* the matches, then shows you the output in a <cyan>human-readable</cyan> fashion. she's giving you the receipts in a format your eyeballs can actually handle. β¨
the whole point? it's meant to give you *some* of the functionality of AT&T's `cscope(1)` tool, but with the advantages of <green>simplicity</green> and <green>not being language-specific</green>. no cap. she doesn't care what language you write in, she's not gonna gatekeep. and if you've configured her that way, the script will <rainbow>colorize</rainbow> the output. π
you'll typically run her with a <purple>Perl regular expression</purple> to search for. want it case insensitive? that's what the `-i` option is for, periodt.
you can also hand her a list of files with an extra argument after the pattern. **important:** put that files pattern in <yellow>quotes</yellow> so it gets matched by <purple>Perl</purple> instead of by the shell. fr fr, the quotes are load-bearing.
run the script with **no arguments at all** and she'll recall the results of your previous search β like a little memory keeper. π§ π
after the search, the entries you found can be edited using the `vg(1)` script. and the `-l` option? that shows you the last log made. easy.
---
# π SOME EXAMPLES π
let's run through them, bestie, because examples are where it all clicks:
- `cg` β just her, alone, no args. this <hotpink>recalls the previous search results</hotpink>. she remembers. π
- `cg -i pattern` β search the **default list of files** for everything matching the pattern, and do it <cyan>case-insensitively</cyan>. lowercase pattern, uppercase results, no problem.
- `cg pattern '*.c'` β search **recursively** for the pattern in all `*.c` files. and here's the cute part: this automatically converts `'*'` to `'.*'` and `'.'` to `'\.'` for you, then does a Perl pattern match on all the files in the tree. she's doing the escaping so you don't have to. π
- `cg pattern *.c` β this one goes through the <yellow>shell-expanded</yellow> list of `*.c` files, so it is **not** done recursively. in other words: only the files your shell passes to the script as arguments. that's it. the shell already did the globbing, so `cg` doesn't get to wander. π¦
- `cg -l` β show the last log made. boom. done.
---
# π
COMMAND-LINE OPTIONS π
- **`-i`** β do a case-insensitive search. case? never heard of her.
- **`-l`** β show the last log made. the receipts, please. π§Ύ
- **`-p`** β toggle the default pager option. so here's the deal: `cg` has a built-in pager function, and it can be enabled or disabled by default (in `.cgvgrc`). if the default is <green>enabled</green>, this option <red>disables</red> the pager; if the default is <red>disabled</red>, this option <green>enables</green> it. it's a toggle, bestie, she flips whichever way you're not already pointing. π
- **`-P`** β force the built-in pager to be **disabled**. no pager, no negotiation. π
---
# π FILES π
- **`${HOME}/.cglast`** β log file of the last search. your most recent receipts, right in your home directory. π
- **`${HOME}/.cgvgrc`** β per-user configuration file, for when the defaults are just not desirable. customize her, she loves that. β¨
- **`${HOME}/.cgvg/*`** β log files in `$HOSTNAME.shell_pid` form, with the log of the last search. yes, she names them by hostname and shell pid, she's organized like that. ποΈ
---
# π₯ SEE ALSO π₯
`vg(1)`, `perl(1)`, `find(1)`, `grep(1)`, `cscope(1)` β the whole friend group, go say hi. π
---
# π AUTHOR π
`cg` was written by <hotpink>Joshua Uziel</hotpink> `<uzi@uzix.org>`. give credit where credit is due, always. π«Ά
---
and that's the whole page, bestie β this version is dated **13 Mar 2002** and belongs to the **`CG(1)`** manual. she's been serving since 2002 and she's still eating. periodt. π
β¨
π¦ where this page comes from
- debian bookworm: cgvg 1.6.2-4 Β· GPL-2.0-or-later
- debian trixie: cgvg 1.6.3-1 Β· GPL-2.0-or-later
- ubuntu jammy: cgvg 1.6.2-4 Β· GPL-2.0-or-later
- ubuntu noble: cgvg 1.6.2-4 Β· GPL-2.0-or-later
- ubuntu questing: cgvg 1.6.3-1
- ubuntu resolute: cgvg 1.6.3-2 Β· GPL-2.0-or-later
- ubuntu stonking: cgvg 1.6.3-3 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms