← 返回命令列表

Linux command

export 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Set

export [VARIABLE]=[value]

Unset

export -n [VARIABLE]

Example

export -f [FUNCTION_NAME]

Append

export PATH=$PATH:[path/to/append]

Print

export -p

说明

export marks shell variables for export to child processes. Exported variables become environment variables visible to all commands run from the shell. When a variable is exported, it's passed to the environment of any command or script executed from that shell. This is essential for configuration like PATH, EDITOR, and application-specific settings that child processes need to inherit. Variables set without export remain local to the current shell. The -n option removes the export attribute while keeping the variable defined. Common in shell scripts and initialization files like .bashrc and .profile.

参数

-n
Remove export property from variable
-f
Export shell functions
-p
Print all exported variables

FAQ

What is the export command used for?

export marks shell variables for export to child processes. Exported variables become environment variables visible to all commands run from the shell. When a variable is exported, it's passed to the environment of any command or script executed from that shell. This is essential for configuration like PATH, EDITOR, and application-specific settings that child processes need to inherit. Variables set without export remain local to the current shell. The -n option removes the export attribute while keeping the variable defined. Common in shell scripts and initialization files like .bashrc and .profile.

How do I run a basic export example?

Run `export [VARIABLE]=[value]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -n do in export?

Remove export property from variable