shell求和、最大值、最小值

shell求和、最大值、最小值

shell脚本如下:

#!/bin/bash
read -p "请输入5个数字 > " num01 num02 num03 num04 num05

echo "5个数值和:$[num01+num02+num03+num04+num05]"

max=${num01}
min=${num01}

for num in ${num01} ${num02} ${num03} ${num04} ${num05}
do
  if ((${num} < ${min}))
  then min=${num}
  fi

  if ((${num} > ${max}))
  then max=${num}
  fi

done
echo "最小值:${min}"
echo "最大值:${max}"

你可能感兴趣的:(shell,linux,运维,服务器)