@bornkiller
2014-11-20T23:42:49.000000Z
字数 2219
阅读 2412
linux
declare [-airx] variable
-a: array
-i: integer
-r: readonly
-x: env variable
var[1]="snowy";
var[2]="winter";
var[3]="summer";
echo ${var[1]};
[root@localhost ~]# echo $test
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/go/bin:/root/bin
[root@localhost ~]# echo ${test##*:}
/root/bin
[root@localhost ~]# echo ${test#*:}
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/go/bin:/root/bin
[root@localhost ~]# echo ${test%%:*}
/usr/lib64/qt-3.3/bin
[root@localhost ~]# echo ${test%:*}
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/go/bin
[root@localhost ~]#
[root@localhost ~]# test=${test#*:}
[root@localhost ~]# echo $test
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/go/bin:/root/bin
[root@localhost ~]# echo ${test/sbin/bin}
/usr/local/bin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/go/bin:/root/bin
[root@localhost ~]# echo ${test//sbin/bin}
/usr/local/bin:/usr/local/bin:/bin:/bin:/usr/bin:/usr/bin:/usr/local/go/bin:/root/bin
//-变量未设置
[root@localhost ~]# echo ${test-love}
love
//:-未设置或为空
[root@localhost ~]# echo ${test:-love}
love
history [n][-c]
#n 最近N条命令
#-c 清除内存命令记录
history [-raw] [histfiles]
!number
#执行编号标记命令
!!
#执行上一条命令
!command
#执行command开头的命令
+ ctrl + c //暂停命令执行
+ ctrl + u //删除整行命令
type | description |
---|---|
; | 无相关性连续操作 |
cmd1&&cmd2 | cmd1正确执行($?=0 )cmd2执行 |
cmd1||cmd2 | cmd1执行出错cmd2才开始执行 |
命令判断从左到右执行
cut -d 'divider' -f 'field'
cut -c [range]
[root@localhost ~]# echo $test
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/go/bin:/root/bin
[root@localhost ~]# echo $test | cut -d ':' -f 3,4
/usr/local/bin:/sbin
# -d,-f配合使用单行截取
# -c 格式化输出单行截取
# cut命令用于单行截取,多空格相连数据处理吃力
grep [-inv] 'string'
# -i 不区分大小写
# -n 输出行号
# -v 取反
sort [-Mnrutk] stdin
# -u unique
# -t 分隔符
# -k key
uniq [-ic]
# -i insensitive
# -c count
wc [-lwm]
# -l line number
# -w word number
# -m character number
tee [-a] file
# 保存数据流
Download link http://pan.baidu.com/s/1jG1fcdK.
gzip -d -c gawk-4.1.1.tar.gz | tar -xvpf -
cd gawk-4.1.1
./configure
make
每一列内容不要有空格或者tab在内。