`

linux set - set variables and set positional parameters

阅读更多
【基本介绍】
set是shell的内置命令。可以用来设置修改变量,设置变量的位置


【参数介绍】
-e当还回值非0是立即退出脚本
-o设置内置环境变量
  set [+abefhkmnptuvxBCEHPT] [+o option] [arg ...]
              -e      Exit immediately if a pipeline (which may consist of a single simple command),  a subshell command enclosed  in  paren-
              -o option-name
                      The option-name can be one of the following:
                      allexport
                              Same as -a.


【基本使用】
1.配置环境变量
[root@pandaVM script]# set | head -10
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist:expand_aliases:extquote:force_fignore:hostcomplete:interactive_comments:login_shell:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="1" [2]="2" [3]="1" [4]="release" [5]="x86_64-redhat-linux-gnu")
BASH_VERSION='4.1.2(1)-release'

[root@pandaVM script]# set +o history # To disable the history storing.
+o disables the given options.

[root@pandaVM script]# set -o history
-o enables the history


2.设置变量参数及位置
[root@pandaVM script]# echo $1 , $2
,
[root@pandaVM script]# set `free | head -2 | tail -1`
[root@pandaVM script]# echo $1 , $2
Mem: , 1012352
[root@pandaVM script]# free | head -2 | tail -1
Mem:       1012352     936836      75516          0     144684     527492



【参考引用】
http://www.thegeekstuff.com/2010/08/bash-shell-builtin-commands/
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics