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.配置环境变量
[code="linux"]
# 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'

# set +o history # To disable the history storing.
+o disables the given options.

# set -o history
-o enables the history
[/code]

2.设置变量参数及位置
[code="linux"]
# echo $1 , $2
,
# set `free | head -2 | tail -1`
# echo $1 , $2
Mem: , 1012352
# free | head -2 | tail -1
Mem: 1012352 936836 75516 0 144684 527492
[/code]


【参考引用】
[url]http://www.thegeekstuff.com/2010/08/bash-shell-builtin-commands/[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值