1.执行shell脚本提示输入并根据输入内容执行
#!/bin/bash if [ $# -ne 3 ];then echo "usage: $(basename $0) par1 par2 par3" exit fi myfunc() { echo $(($1*$2*$3)) } result=`myfunc $1 $2 $3` echo "$result"
2.替换变量中的子字符串(空格)
myStr="hello world" myWhiteSpaceChar="{_}" myStr=`echo $myStr |sed "s# #$myWhiteSpaceChar#g"` echo $myStr 输出: hello{_}world
3.替换文件中的子字符串(空格)并输出到新的文件
myWhiteSpaceChar="{_}" sed "s# #${myWhiteSpaceChar}#g" ${tmpDir}/api.records.tmp >${tmpDir}/api.records.deal.tmp
标签:shell,myWhiteSpaceChar,echo,sed,result,myStr,大全,技能 From: https://www.cnblogs.com/franson-2016/p/17830966.html