In the first synopsis form, getconf writes the value of the variable specified by the system_var operand to the standard output.
In the second syntax form, getconf writes the value of the variable specified by the path_var operand to the standard output. This value is valid within the path specified by the pathname operand.
The value of each configuration variable is output as if it were determined by calling the function from which it was defined. The value reflects the conditions in the current execution environment.
If the specified variable is valid, but is not defined on the system, getconf writes %undefined
to the standard output.
Syntax
Format 1: |
getconf system_var |
Format 2: |
getconf path_var pathname |
Name of a configuration variable whose value can be obtained using the confstr() or sysconf() functions [4]. The following values are supported: ARG_MAX, BC_BASE_MAX, BC_DIM_MAX, BC_SCALE_MAX, BC_STRING_MAX, CHAR_BIT, CHAR_MAX, CHAR_MIN, CHARCLASS_NAME_MAX, CHILD_MAX, CLK_TCK, COLL_WEIGHTS_MAX, CS_PATH, EXPR_NEST_MAX, INT_MAX, INT_MIN, LINE_MAX, LONG_BIT, LONG_MAX, LONG_MIN, MB_LEN_MAX, NGROUPS_MAX, NL_ARGMAX, NL_ARGMAX, NL_LANGMAX, NL_LANGMAX, NL_MAX, NL_MAX, NL_MSGMAX, NL_MSGMAX, NL_SETMAX, NL_SETMAX, NL_TEXTMAX, NL_TEXTMAX, NZERO, OPEN_MAX, POSIX_ARG_MAX, POSIX_CHILD_MAX, POSIX_JOB_CONTROL, POSIX_LINK_MAX, POSIX_MAX_CANON, POSIX_MAX_INPUT, POSIX_NAME_MAX, POSIX_NGROUPS_MAX, POSIX_OPEN_MAX, POSIX_PATH_MAX, POSIX_PIPE_BUF, POSIX_SAVED_IDS, POSIX_SSIZE_MAX, POSIX_STREAM_MAX, POSIX_TZNAME_MAX, POSIX_VERSION, POSIX2_BC_BASE_MAX, POSIX2_BC_DIM_MAX, POSIX2_BC_SCALE_MAX, POSIX2_BC_STRING_MAX, POSIX2_C_BIND, POSIX2_C_DEV, POSIX2_C_VERSION, POSIX2_CHAR_TERM, POSIX2_COLL_WEIGHTS_MAX, POSIX2_EXPR_NEST_MAX, POSIX2_FORT_DEV, POSIX2_FORT_RUN, POSIX2_LINE_MAX, POSIX2_LOCALEDEF, POSIX2_RE_DUP_MAX, POSIX2_SW_DEV, POSIX2_UPE, POSIX2_VERSION, RE_DUP_MAX, SCHAR_MAX, SCHAR_MIN, SHRT_MAX, SHRT_MIN, SSIZE_MAX, STREAM_MAX, TMP_MAX, TZNAME_MAX, UCHAR_MAX, UINT_MAX, ULONG_MAX, USHRT_MAX, WORD_BIT, XOPEN_CRYPT, XOPEN_ENH_I18N, XOPEN_SHM, XOPEN_VERSION, XOPEN_XCU_VERSION, XOPEN_XPG2, XOPEN_XPG3, XOPEN_XPG4 The symbol PATH is also recognized. It returns the same value as the confstr() [4] value CS_PATH. getconf also recognizes the variables LOGNAME_MAX, PAGE_SIZE, PAGESIZE, PASS_MAX All variable names can be specified with or without a leading underscore (_).
Name of a configuration variable whose value can be obtained using the pathconf() [4] function. The following values are supported: LINK_MAX, MAX_CANON, MAX_INPUT, NAME_MAX, PATH_MAX, PIPE_BUF, POSIX_CHOWN_RESTRICTED, POSIX_NO_TRUNC, POSIX_VDISABLE All variable names can be specified with or without a leading underscore (_).
Pathname for which the variable specified by path_var is to be determined. |
Locale
The following environment variables affect the execution of getconf: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Exit status
The following exit values are returned:
|
Example 1
In this example, the value of {NGROUPS_MAX} is obtained (Format 1):
|
Example 2
In this example, the value of {NAME_MAX} is obtained for a specific directory (Format 2):
|
Example 3
This example shows how to deal more carefully with results that mightbe unspecified: if value=$(getconf PATH_MAX /usr); then if [ "$value" = "undefined" ]; then echo PATH_MAX in /usr is infinite. else echo PATH_MAX in /usr is $value. fi else echo Error in getconf. fi Note that the following calls in a C program could return different results:
and:
The sysconf() [4] call returns a value that corresponds to the conditions when the program is either compiled or executed. The system() [4] call to getconf always returns a value that corresponds to the conditions when the program is executed. |
See also
pathconf(), confstr(), sysconf() [4] |