在 Debian(以及其它使用 glibc 的系统)里,getconf 本身没有“列出所有变量”的标准选项,但可以用下面几种方式达到目的。
getconf -a 可以列出 getconf 支持的所有变量及其当前值(来自 limits.h / unistd.h 等)。
getconf -a
示例输出:
LINK_MAX 32000
POSIX_VERSION 200809
PAGE_SIZE 4096
...
注意:
-a不是 POSIX 标准,但在 Debian/glibc 上是可用的。
getconf -a | awk '{print $1}'
getconf PAGE_SIZE
getconf LONG_BIT
getconf -a | grep PATH
或者:
getconf PATH
这些来自 <unistd.h>:
getconf -a | grep -i posix
如果是想看 shell 环境变量:
env
# 或
printenv
getconf --help
man getconf
| 目的 | 命令 |
|---|---|
| 列出所有 getconf 变量 | getconf -a |
| 只看变量名 | `getconf -a |
| 查看某个变量 | getconf VAR |
| 查看环境变量 | env / printenv |
如果你是想写脚本自动遍历所有 getconf 变量并取值,我也可以给你一个示例脚本。