shell脚本的变量赋值
2018-02-27 22:15
471 查看
parameter相关知识
${parameter:-word}:如果parameter为空或未定义,则变量展开为“word”;否则,展开为parameter的值; ${parameter:+word}:如果parameter为空或未定义,不做任何操作;否则,则展开为“word”值;否则什么都不做 ${parameter:=word}:如果parameter为空或未定义,则变量展开为“word”,并将展开后的值赋值给parameter; ${parameter:offset} ${parameter:offset:length}:取子串,从offset处的后一个字符开始,取lenth长的子串; -号 [root@feitian etc]# a=3 [root@feitian etc]# echo ${a:-30} 3 [root@feitian etc]# unset a [root@feitian etc]# echo ${a:-30} 30 [root@feitian etc]# echo $a +号 [root@feitian etc]# echo $a #结果为空 [root@feitian etc]# echo ${a:+30} #结果为空 [root@feitian etc]# a=1 [root@feitian etc]# echo ${a:+30} 30 =号 [root@feitian etc]# echo $a 1 [root@feitian etc]# echo ${a:=30} 1 [root@feitian etc]# echo $a 1 [root@feitian etc]# unset a [root@feitian etc]# echo ${a:=30} 30 [root@feitian etc]# echo $a 30 变量赋值的相关内容 [root@feitian etc]# a="hello world" [root@feitian etc]# echo ${a:2:3} llo [root@feitian etc]# echo ${a:2} llo world
相关文章推荐
- 在shell脚本文件中获取该脚本所在的路径,并赋值给一个变量
- SHELL 关于变量的赋值和脚本中的子SHELL中变量的变化
- Shell 脚本分割变量分别赋值与sed 应用打印特殊行
- linux之基础shell脚本编程1 基础变量赋值
- 通过脚本的方式杀tomcat进程(shell脚本),shell中将一个文件的内容读出赋值给一个变量
- linux 将文件内容赋值给shell脚本中的变量
- shell 脚本中将输出内容赋值给一个变量时的换行问题
- Shell脚本中赋值变量时单引号‘和双引号“的区别
- linux中的for、while循环输出中赋值变量及shell中循环获取脚本参数
- shell脚本的作用,shell脚本变量的定义和三种赋值方式【shell脚本的学习笔记一】
- Shell脚本定义变量和重新赋值
- shell脚本中变量的赋值与循环--工程小札记
- linux之基础shell脚本编程4 字符串操作,变量赋值,配置用户环境
- shell脚本取出mysql中的值,然后赋值给shell的变量
- shell 脚本中将输出内容赋值给一个变量时不换行
- shell 脚本:使用过程中使得变量能够赋值
- shell脚本中赋值给变量中有空格, 导致命令执行失败
- shell脚本中使用了管道符,导致变量赋值丢失的原因
- shell脚本中变量的赋值
- shell脚本标准输出赋值给变量