12 2022 档案
摘要:shell脚本猜0到100之间的随机数 #!/bin/bash echo "input a number between 1 and 100" let num=$((RANDOM %100)) # echo $num while true do read guess if [ $guess -lt
阅读全文
摘要:##shell脚本实现求和 ###1: 1+2+...+9+10 #!/bin/bash let init=0 for i in {1..10..1} do # echo $sum let sum=$sum+$i done echo $sum 运行结果 2: 1+3+...+9 #!/bin/bas
阅读全文
摘要:#!/bin/bash let isPrime=1 echo "input a number: " read n if [ ${n} -le 1 ] then let isPrime=2 fi for ((i=2;i<n;i++)) do let tmp=$(($n%$i)) if [ $tmp -
阅读全文