Linux command
printenv 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Print all environment variables
printenv
Print specific variable
printenv [HOME]
Print multiple variables
printenv [PATH] [USER] [SHELL]
Print with null separator
printenv -0
说明
printenv prints the values of environment variables. When called without arguments, it prints all environment variables. When given variable names as arguments, it prints only those values. Unlike `echo $VAR`, printenv shows nothing (and returns non-zero) for undefined variables, making it useful for testing variable existence in scripts. printenv is part of GNU coreutils and provides a straightforward way to inspect the shell environment.
参数
- -0, --null
- End each line with NUL instead of newline.
- --help
- Display help information.
- --version
- Display version information.
FAQ
What is the printenv command used for?
printenv prints the values of environment variables. When called without arguments, it prints all environment variables. When given variable names as arguments, it prints only those values. Unlike `echo $VAR`, printenv shows nothing (and returns non-zero) for undefined variables, making it useful for testing variable existence in scripts. printenv is part of GNU coreutils and provides a straightforward way to inspect the shell environment.
How do I run a basic printenv example?
Run `printenv` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -0, --null do in printenv?
End each line with NUL instead of newline.