CONFGET(1)
π CONFGET β read a variable from a configuration file π
okay bestie, gather round, because this one is so useful and nobody talks about it. confget reads variables out of your config file so your shell scripts can stop copy-pasting settings. it's giving "finally, one source of truth." π
πΈ SYNOPSIS πΈ
confget [-cOSx] [-N | -n] [-f filename] [-m pattern] [-P postfix]
[-p prefix] [-s section] [-t type] varname...
confget [-OSx] [-N | -n] [-f filename] [-m pattern] [-P postfix]
[-p prefix] [-s section] [-t type] -L pattern...
confget [-OSx] [-N | -n] [-f filename] [-m pattern] [-P postfix]
[-p prefix] [-s section] [-t type] -l
confget [-f filename] -q sections [-t type]
confget [-hTV]
like, five whole moods. pick your fighter. π
β¨ DESCRIPTION β¨
The confget utility examines a INI-style configuration file and retrieves the value of the specified variables from the specified section. Its intended use is to let shell scripts use the same INI-style configuration files as other programs, to avoid duplication of data.
fr fr. that's the whole point: one config file, everybody reads from it, nobody duplicates anything. the dream. π¦
The confget utility may retrieve the values of one or more variables, list all the variables in a specified section, list only those whose names or values match a specified pattern (shell glob or regular expression), or check if a variable is present in the file at all. It has a βshell-quotingβ output mode that quotes the variable values in a way suitable for passing them directly to a Bourne-style shell.
so it does four things: grab values, list a section, filter by pattern, check existence. plus it can quote stuff so you can yeet it straight into a shell. iconic. π₯
π Options π
-cβ Check-only mode; exit with a code of0if any of the variables are present in the configuration file, and1if there are none.-ffilename β Specify the configuration file to read from, or β-β (a single dash) for standard input.-hβ Display program usage information and exit.-Lβ Variable list mode; display the names and values of all variables in the specified section with names matching one or more specified patterns.-lβ List mode; display the names and values of all variables in the specified section.-mpattern β Only display variables with if their values match the specified pattern.-Nβ Always display the variable name along with the value.-nβ Never display the variable name, only the value.-Oβ Allow variables in the specified section to override variables in the unnamed section at the start of the file. This is the only case whenconfgeteven considers variables in more than one section.-Ppostfix β Display this string after the variable name as a postfix.-pprefix β Display this string before the variable name as a prefix.-qquery β Query for a specific type of information. For the present, the only supported value for the query argument is βsectionsβ, which lists the names of the sections defined in the configuration file.-Sβ Quote the variable values so that the βvar=valueβ lines may be passed directly to the Bourne shell.-ssection β Specify the configuration section to read. If this option is specified,confgetwill only consider variables defined in the specified section; see the-Ooption for the only exception.
If this option is not specified, confget will use the first section found in the configuration file. However, if the configuration file contains variable definitions before a section header, confget will only examine them instead.
If the -s option is specified with an empty string as the section name, confget will only examine variables defined before any section header (a βrealβ unnamed default section); this is incompatible with the -O option.
ok this one has layers, bestie. read it twice. and note that empty-string-sand-Oare not a thing together β they do not vibe. π
-Tβ List the available configuration file types that may be selected by the-toption.-ttype β Specify the configuration file type.-Vβ Display program version information and exit.-xβ Treat the patterns as regular expressions instead of shell glob patterns.
π ENVIRONMENT π
Not taken into consideration.
that's it. that's the section. she does not care about your env vars, and honestly? respect. π
π EXIT STATUS π
If the -c option is specified, the confget utility will exit with a status of 0 if any of the specified variables exist in the config file and 1 if none of them are present.
In normal operation, no matter whether any variables were found in the configuration file or not, the confget utility exits with a status of 0 upon normal completion. If any errors should occur while accessing or parsing the configuration file, the confget utility will display a diagnostic message on the standard error stream and exit with a status of 1.
so: 0 = we good, 1 = something went sideways (or, with -c, "nope, not found"). and yeah, with -c a "not found" is a 1, that's on purpose, that's the whole feature. π
π EXAMPLES π
Retrieve the variable machine_id from the system section of a configuration file:
confget -f h.conf -s system machine_id
Retrieve the variable hostname from the db section, but only if it ends in β.ringlet.netβ:
confget -f h.conf -s db -m '*.ringlet.net' hostname
Display the names and values of all variables declared before any section has been defined:
confget -f h.conf -s '' -l
Display the names and values of all variables in the system section with names beginning with βmachβ or ending in βnameβ, appending a βcfg_β at the start of each variable name:
confget -f h.conf -s system -p 'cfg_' -L 'mach*' '*name'
Display the names and values of all variables in the system section:
confget -f h.conf -s system -l
Safely read the contents of the db section:
eval `confget -f h.conf -s db -p db_ -S -l`
that last one is the main character of this page, ngl.-Squotes everything,-p db_prefixes every name, andevaldrops it all straight into your shell. chef's kiss. ππ₯
π SEE ALSO π
For another way to parse INI files, see the Config::IniFiles(3) Perl module.
π§ STANDARDS π§
No standards documentation was harmed in the process of creating confget.
(genuinely obsessed with this sentence. no notes. periodt. β¨)
π BUGS π
Please report any bugs in confget to the author.
π«Ά AUTHOR π«Ά
The confget utility was conceived and written by Peter Pentchev <roam@ringlet.net> in 2008.
and that's the whole page, bestie π this Debian build is dated May 9, 2021, and the manual page itself is CONFGET(1) β go forth and stop duplicating your config data, you absolute icon. πΈππ
π¦ where this page comes from
- debian trixie: confget 5.1.2-2 Β· BSD-2-Clause
- ubuntu noble: confget 5.1.2-1 Β· BSD-2-Clause
- ubuntu questing: confget 5.1.2-2
- ubuntu resolute: confget 5.1.2-3 Β· BSD-2-Clause
- ubuntu stonking: confget 5.1.2-3 Β· BSD-2-Clause
- π the page's license: BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms