unset

删除变量或函数名称

语法

  unset [-fv] [name]

选项

  -f    仅删除函数

  -v    仅删除变量

除非名称不存在或只读,否则返回状态为零

unset是一个内置命令的bash

例子

[root@linux ~]# aaa=bbb          #设置本地变量

[root@linux ~]# echo $aaa        #显示变量的值
bbb

[root@linux ~]# set|grep aaa     #查看本地变量
aaa=bbb

[root@linux ~]# unset aaa        #删除环境变量

unset 命令实例:

linux命令:unset export HISTCONTROL HISTCONTROL export unset unset export HISTCONTROLrootopen.com
linux命令:unset export HISTCONTROL HISTCONTROL export unset unset export HISTCONTROLrootopen.com
2018-09-11 09:55:30

linux命令:unset files i; set -f; O=$IFS; while IFS= read -r -d $'\0' files[i++]; do :; done < <(find . -name '*.avi' -print0) && IFS=$O; set +f && echo "Running: mplayer \"${files[ $(( $RANDOM % ${#files[@]} )) ]}\"" ]}\"" )) ${#files[@]} % $RANDOM $(( \"${files[ mplayer "Running: echo && +f set IFS=$O; && -print0) '*.avi' -name . <(find < done :; do files[i++]; $'\0' -d -r read IFS= while O=$IFS; -f; set i; files unset unset files i; set -f; O=$IFS; while IFS= read -r -d $'\0' files[i++]; do :; done < <(find . -name '*.avi' -print0) && IFS=$O; set +f && echo "Running: mplayer \"${files[ $(( $RANDOM % ${#files[@]} )) ]}\""rootopen.com
linux命令:unset files i; set -f; O=$IFS; while IFS= read -r -d $'\0' files[i++]; do :; done < <(find . -name '*.avi' -print0) && IFS=$O; set +f && echo "Running: mplayer \"${files[ $(( $RANDOM % ${#files[@]} )) ]}\"" ]}\"" )) ${#files[@]} % $RANDOM $(( \"${files[ mplayer "Running: echo && +f set IFS=$O; && -print0) '*.avi' -name . <(find < done :; do files[i++]; $'\0' -d -r read IFS= while O=$IFS; -f; set i; files unset unset files i; set -f; O=$IFS; while IFS= read -r -d $'\0' files[i++]; do :; done < <(find . -name '*.avi' -print0) && IFS=$O; set +f && echo "Running: mplayer \"${files[ $(( $RANDOM % ${#files[@]} )) ]}\""rootopen.com
2018-05-09 16:42:48

linux命令:unset HISTFILE HISTFILE unset unset HISTFILErootopen.com
linux命令:unset HISTFILE HISTFILE unset unset HISTFILErootopen.com
2018-01-05 18:13:48

linux命令:unset TMOUT TMOUT unset unset TMOUTrootopen.com
linux命令:unset TMOUT TMOUT unset unset TMOUTrootopen.com
2018-01-20 14:35:48

linux命令:unset MANPATH; manpath >/dev/null >/dev/null manpath MANPATH; unset unset MANPATH; manpath >/dev/nullrootopen.com
linux命令:unset MANPATH; manpath >/dev/null >/dev/null manpath MANPATH; unset unset MANPATH; manpath >/dev/nullrootopen.com
2018-03-29 11:18:48

linux命令:unset HISTFILE HISTFILE unset unset HISTFILErootopen.com
linux命令:unset HISTFILE HISTFILE unset unset HISTFILErootopen.com
2018-04-26 01:00:48

linux命令:unset HISTFILE HISTFILE unset unset HISTFILErootopen.com
linux命令:unset HISTFILE HISTFILE unset unset HISTFILErootopen.com
2018-05-05 18:44:48

Linux的Bash命令行(A-Z排序)