getconf - 获取配置值
/usr/bin/getconf [-v specification] system_var
/usr/bin/getconf [-v specification] path_var pathname
/usr/bin/getconf -a
/usr/xpg4/bin/getconf [-v specification] system_var
/usr/xpg4/bin/getconf [-v specification] path_var pathname
/usr/xpg4/bin/getconf -a
/usr/xpg6/bin/getconf [-v specification] system_var
/usr/xpg6/bin/getconf [-v specification] path_var pathname
/usr/xpg6/bin/getconf -a
/usr/xpg7/bin/getconf [-v specification] system_var
/usr/xpg7/bin/getconf [-v specification] path_var pathname
/usr/xpg7/bin/getconf -a
在第一个用法概要形式中,getconf 实用程序会将 system_var 指定的变量值写入标准输出,如果使用了 –v 选项,则与 specification 一致。
在第二个用法概要形式中,getconf 会为 pathname 指定的路径,将 path_var 指定的变量值写入标准输出,如果使用了 – v 选项,则与 specification 一致。
在第三个用法概要形式中,config 会将当前系统配置变量的名称写入标准输出。
确定每个配置变量的值时,会将其视为通过调用将其定义为可供使用的函数而获取。值反映当前操作环境中的条件。
支持以下选项:
将当前系统配置变量的所有名称及其值写入标准输出。
给出可管理为配置变量选择值的规范。
支持下列操作数:
配置变量的名称,其值可通过 pathconf(2) 函数获取。
路径名,将为其确定 path_var 指定的变量。
配置变量的名称,其值可通过系统接口 confstr(3C) 或 sysconf(3C) 获取,或者在系统头文件 limits.h(3HEAD) 或 unistd.h(3HEAD) 中定义。
也可识别 PATH 符号,产生的值与 confstr() 名称值 CS_PATH 相同。
本示例说明了 {NGROUPS_MAX} 的值:
example% getconf NGROUPS_MAX示例 2 为特定目录编写变量的值
本示例说明了特定目录的 NAME_MAX 值:
example% getconf NAME_MAX /usr示例 3 处理不确定的结果
本实例显示了如何更谨慎地处理可能不确定的结果:
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
例如:
sysconf(_SC_POSIX_C_BIND);
和
system("getconf POSIX2_C_BIND");
C 程序可能给出不同答案。sysconf 调用提供与程序编译或执行时的条件对应的值,具体取决于实现情况。对 getconf 的 system 调用始终提供与程序执行时的条件对应的值。
有关影响 getconf 执行的以下环境变量的说明,请参见 environ(7):LANG、LC_ALL、LC_CTYPE、LC_MESSAGES 和 NLSPATH。
将返回以下退出值:
指定的变量有效,且关于其当前状态的信息已成功写入。
出现错误。
有关下列属性的说明,请参见 attributes(7):
|
sh(1)、pathconf(2)、sysinfo(2)、confstr(3C)、sysconf(3C)、attributes(7)、environ(7)、standards(7)