linux,shell逻辑运算

shell编程我们要遵循其格式,遇到问题要反思,有的时候是空格,$,括号,参数下标,等问题,熟悉之后很多问题都可以很快解决,把更多的精力放在逻辑梳理上面

source ./test1.sh
function func2(){
  first_name=$1
  middle_name=$2
  family_name=$3

  echo $first_name
  echo $middle_name
  echo $family_name
}

echo "菜鸟教程官网地址:$url"
# 使用$(func_name arg1 arg2 ...)来获取函数中所有的echo值
res3=$(func2 "tony" "kid"   "leung")
echo "func2 'tony' 'kid'  'leung' RESULT IS____"$res3

res4=$(func2 'who' 'is' 'the' 'most' 'handsome' 'guy?')
func2 'who' 'is' 'the' 'most' 'handsome' 'guy?'

echo "func2 'who' 'is' 'the' 'most' 'handsome' 'guy?' RESULT IS____"$res4

if [[ $res4 =~ "the" ]]; then
  echo "it includes tony ^_^ "
else
  echo "Input name doesn't include 'tony'!"
fi

猜你喜欢

转载自blog.csdn.net/zhilinboke/article/details/82021251