1.if if command then commands fi if command then commands else commands fi if command1 then command elif command2 then command elif command3 then command fi 2.test: 用于if条件中 if test condition then commands fi if [condition] then commands fi test有三种比较场…
Linux shell脚本编程(二) 练习:求100以内所有偶数之和; 使用至少三种方法实现; 示例1: #!/bin/bash # declare -i sum=0 #声明一个变量求和,初始值为0 for i in $(seq 0 2 100); do sum=$(($sum+$i)) done echo "Even sum: $sum." 示例2: #!/bin/bash # declare -i sum=0 for i in {1..100}; do if [ $[$i%2] -…