Bash变量扩展修改符 1、未设置就临时替换(:-) 冒号:用来检验变量是否设置过,如果没有冒号,则认为设置过,不替换 $fruit=peach $echo ${fruit:-plum} peach$fruit= $echo ${fruit:-plum} plum$echo $fruit $2、未设置就永久替换(:=) $name= $echo ${name:=Peter} Peter$echo $name Peter3、设置了就临时替换(:+) $foo=grapes $echo ${foo:+pears} pears $echo $foo grapes4、未设置就打印消息(:?) $echo ${namex:?"namex is undefined"} namex: namex is undefined$echo name=${1:?"requires an argument"} //适用于脚本中检测位置参量 1: requires an argumentecho ${y?} y: parameter null or not set //打印默认消息5、子字符串(:m:n) $var=notebook$echo ${var:0} notebook$echo ${var:0:4} note$echo ${var:4:4} book Bash函数简述 http://www.linuxidc.com/Linux/2015-06/118796.htmLinux Bash脚本编程语言中的美学与哲学 http://www.linuxidc.com/Linux/2015-03/114436.htm提高Linux工作效率的十大bash技巧 http://www.linuxidc.com/Linux/2015-03/114349.htmbash的登录与欢迎信息:/etc/issue,/etc/motd http://www.linuxidc.com/Linux/2014-08/105419.htmBash常用的几个配置文件 http://www.linuxidc.com/Linux/2014-08/105202.htmBash脚本15分钟进阶教程 http://www.linuxidc.com/Linux/2014-04/100750.htm10个 Linux/Unix下 Bash 和 KSH shell 的作业控制实例 http://www.linuxidc.com/Linux/2014-03/98159.htmUbuntu下shell脚本运行异常:Bash和dash的区别 http://www.linuxidc.com/Linux/2013-10/91100.htmBash脚本之for语句if语句以及各种测试语句 http://www.linuxidc.com/Linux/2013-07/87922.htm什么是Bash Shell的内建(build in)命令 http://www.linuxidc.com/Linux/2013-06/86039.htm分享有用的 bash 别名和函数 http://www.linuxidc.com/Linux/2015-01/111178.htmLinux Bash Shell入门教程 http://www.linuxidc.com/Linux/2013-08/8848.htm本文永久更新链接地址 :http://www.linuxidc.com/Linux/2015-08/120885.htm
收藏该网址