linux下的set, export, env的区别

set和export的区别

set可以用来显示所有变量的值,而export能将一个变量导出,在其子shell或子进程也可见

export和env的区别

两者的作用是一样的,只是env是一个外部工具

基本用法

单纯使用set,可以看到当前shell所定义的所有变量,包含局部和导出;可使用unset 删除一个变量
使用export(env)可以看到所有导出的变量(也就是环境变量); 可使用export VARIABLE的方式定义一个环境变量,或导出一个局部变量为环境变量。

ref

What's the difference of the command output after inputting the command “env”, “export”, “set” under Bash Shell in Solaris?

原文地址:https://www.cnblogs.com/ishen/p/11993540.html