UCG(1)
πΈ ucg: the source-code grep bestie (UCG(1)) πΈ
hiii bestie, welcome to the UCG(1) page from the General Commands Manual β yes, that manual, and yes, we're doing this with sparkle. β¨
π NAME
ucg β a grep-like tool for searching source code. That's the whole vibe: grep-like, but for source code, and it's iconic. π
π SYNOPSIS
ucg [ OPTIONS ] PATTERN [ FILES OR DIRECTORIES ]
π DESCRIPTION
okay so ucg (UniversalCodeGrep) is an extremely fast grep-like tool specialized for searching large bodies of source code. It is intended to be largely command-line compatible with ack, to some extent with ag, and β where appropriate β with grep(1). Search patterns are specified as pcre(3) regular expressions. No cap, that's the spec. π¦
β¨ OPTIONS β¨
π Searching:
--[no]smart-caseβ Ignore case if PATTERN is all lowercase (default: enabled). Smart-case is literally doing the vibe check for you.-i,--ignore-caseβ Ignore case distinctions in PATTERN.-Q,--literalβ Treat all characters in PATTERN as literal. No regex shenanigans.-w,--word-regexpβ PATTERN must match a complete word. Whole word only, periodt.
π€ Search Output:
--columnβ Print column of first match after line number.--nocolumnβ Don't print column of first match (default). That's the default, bestie.
π¨ File presentation:
--color,--colourβ Render the output with ANSI color codes. Cute.--nocolor,--nocolourβ Render the output without ANSI color codes.
π File/directory inclusion/exclusion:
--[no]ignore-dir=NAME,--[no]ignore-directory=NAMEβ [Do not] exclude directories with NAME. The[no]is doing a lot of work, iykyk.--exclude=GLOB,--ignore=GLOBβ Files matching GLOB will be ignored.--ignore-file=FILTER:FILTERARGSβ Files matchingFILTER:FILTERARGS(e.g.ext:txt,cpp) will be ignored. Example is literal, don't come for me.--include=GLOBβ Only files matching GLOB will be searched.-k,--known-typesβ Only search in files of recognized types (default: on).-n,--no-recurseβ Do not recurse into subdirectories.-r,-R,--recurseβ Recurse into subdirectories (default: on).--type=[no]TYPEβ Include only [exclude all] TYPE files. Types may also be specified as--[no]TYPE.
𧬠File type specifications:
--type-add=TYPE:FILTER:FILTERARGSβ Files FILTERed with the given FILTERARGS are treated as belonging to type TYPE. Any existing definition of type TYPE is appended to.--type-del=TYPEβ Remove any existing definition of type TYPE.--type-set=TYPE:FILTER:FILTERARGSβ Files FILTERed with the given FILTERARGS are treated as belonging to type TYPE. Any existing definition of type TYPE is replaced.
β‘ Performance tuning:
--dirjobs=NUM_JOBSβ Number of directory traversal jobs (std::thread<>s) to use.-j,--jobs=NUM_JOBSβ Number of scanner jobs (std::thread<>s) to use.
π§ Miscellaneous:
--noenvβ Ignore.ucgrcconfiguration files. Like, fully ignore them. periodt.
π Informational options:
-?,--helpβ Print a list of options.--help-types,--list-file-typesβ Print a list of supported file types.--usageβ Print a brief usage message.-V,--versionβ Print program version.
bestie note: Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options. That's not me being extra, that's the manual. π
π EXIT STATUS
Exit status is 0 if any matches were found, 1 if no matches, 2 or greater on error. So if you get 2+, something went sideways, bestie. Don't ignore it. π
ποΈ FILES
ucg supports configuration files with the name .ucgrc in which command-line options can be stored on a per-user and per-directory-hierarchy basis. It's giving config file era. π
π Format:
.ucgrc files are text files with a simple format. Each line of text can be either:
- A single-line comment. The line must start with a
#and the comment continues for the rest of the line. - A command-line parameter. This must be exactly as if it was given on the command line.
π Location and Read Order:
When ucg is invoked, it looks for command-line options from the following locations in the following order:
- The
.ucgrcfile in the user's$HOMEdirectory, if any. - The first
.ucgrcfile found, if any, by walking up the component directories of the current working directory. This traversal stops at either the user's$HOMEdirectory or the root directory. This is the project config file, and is intended to live in the top-level directory of a project directory hierarchy. - The command line itself.
Options read later will override earlier options. So later wins, periodt. π₯
π¨ Creating User-Defined File Types:
ucg supports the creation of user-defined file types with the following options:
--type-set=TYPE:FILTER:FILTERARGS--type-add=TYPE:FILTER:FILTERARGS
Any number of type filters, in any combination, can be added to a single file TYPE.
Three types of FILTERs are currently supported:
ext(extension list)is(literal filename)glob(glob pattern)
π Extension List Filter
The extension list filter allows you to specify a comma-separated list of file extensions which are to be considered as belonging to file type TYPE. For example:
ucg --type-set=type1:ext:abc,xqz,def --type1 'Pattern'
will search all files with extensions *.abc, *.xqz, and *.def in the directory tree rooted at the current working directory for the literal string 'Pattern'. Slay. π
π§Έ Literal Filename Filter
The literal filename filter simply specifies a single literal filename which is to be considered as belonging to file type TYPE.
Example:
ucg --type-add=autoconf:is:configure.ac --autoconf 'Pattern'
This will search only files named exactly 'configure.ac' for the literal string 'Pattern'. Exactly, no side quests. π
π¦ Glob filter
The glob filter allows you to specify a glob pattern to match against filenames. If the glob matches, the file is considered as belonging to the file type TYPE.
Example:
ucg --type-set=mk:glob:?akefile* --mk 'Pattern'
This will search only files which match the shell glob pattern '?akefile*' (e.g. Makefile, makefile, Bakefile.bkl, etc.) for the literal string 'Pattern'. Not me obsessing over '?akefile*', it's just iconic. π
π BUGS
Report bugs to β¨https://github.com/gvansickle/ucg/issuesβ©. Please don't suffer in silence, bestie. π
π AUTHOR
ucg is written by Gary R. Van Sickle β¨grvs@users.sourceforge.netβ©. Respect the author, periodt. π«Ά
π SEE ALSO
The official UniversalCodeGrep site β¨https://github.com/gvansickle/ucgβ© on GitHub.
okay that's the whole UCG(1) manual, bestie β source/version tag UCG(1), dated 2016-10-31. mwah ππ«Ά
π¦ where this page comes from
- nixpkgs unstable: ucg-unstable 2022-09-03
- Copyright 2016 Gary R. Van Sickle (grvs@users.sourceforge.net)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms