The difference between export command and source command under linux

 

The export command under Linux is used to set or display environment variables.

$ help export
export: export [-fn] [名称[=值] ...] 或 export -p
    为 shell 变量设定导出属性。
    
    标记每个 NAME 名称为自动导出到后续命令执行的环境。如果提供了 VALUE
    则导出前将 VALUE 作为赋值。
    
    选项:
      -f	指 shell 函数
      -n	删除每个 NAME 名称的导出属性
      -p	显示所有导出的变量和函数的列表
    
    `--' 的参数禁用进一步的选项处理。
    
    退出状态:
    返回成功,除非使用了无效的选项或者 NAME 名称。

When executing a program in the shell, the shell provides a set of environment variables. Export can add, modify or delete environment variables for subsequent execution of the program. The effect of export is limited to this login operation.

After importing environment variables using the export command, write:

export -p

Will output the current environment variables in the terminal

 


The source command under linux:

$ help source
source: source 文件名 [参数]
    在当前 shell 中执行一个文件中的命令。
    
    在当前 shell 中读取并执行 FILENAME 文件中的命令。$PATH 变量中的
    条目被用于寻找包含 FILENAME 文件的目录。如果提供了任何的 ARGUMENTS
    参数,则它们将成为 FILENAME 文件执行时的位置参数。
    
    退出状态:
    返回 FILENAME 文件中最后一个命令的状态;如果 FILENAME 文件不可读则失败。

The source is equivalent to the. command, which is equivalent to executing the content of the file following the source in the terminal.

 

Guess you like

Origin blog.csdn.net/sinat_39416814/article/details/103762487