linux 有很多种shell, 其中 bash 最出名,
相关的学习资料,可以到 :
http://www.runoob.com/linux/linux-shell.html
其中有一个很有用的,实际操作方式
http://www.runoob.com/try/runcode.php?filename=helloworld&type=bash
注意:执行时,如果是指定目录的shell,一定要输入目录,如./xxx.sh
不然,只输入xxx.sh,会到path中找,和当前目录找,如果path中其他地方有,很容易出错。
常见形式说明
#检查$BASH是否来空
[ -z "$BASH" ]
[ -z "$BASH" ] && { echo "Configure requires bash" 1>&2; exit 1; }
检查$BASH是否为空,如果是,显示""Configure requires bash",并把显示结果输出到std-err,并返回1.
在 shell 程式中,最常使用的 FD (file descriptor) 大概有三个, 分别是:
0 是一个文件描述符,表示标准输入(stdin)
1 是一个文件描述符,表示标准输出(stdout)
2 是一个文件描述符,表示标准错误(stderr)
sed -e 's/\([0-9]\)[:].*/\1 /g'
分段后为:
sed -e 's/ \([0-9]\)[:].* / \1 /g'
意思:查找以[0-9]:.字符,用"1 "替换,以及[0-9]:.后面的全部del
实例:
cmd:
echo "abc_000123456:.log " | sed -e 's/\([0-9]\)[:].*/\1 /g'
显示结果:(需要去掉左右两个")
"abc_000123456 "