qfedu-linux-advanced-level/day1/homework/h5.sh

14 lines
289 B
Bash
Raw Normal View History

2023-08-14 20:13:50 +08:00
#!/bin/bash
# 编写一个Shell脚本接受一个数字作为参数并判断该数字是奇数还是偶数。
if [ $# -ne 1 ]; then
echo "参数个数不正确"
exit 1
else
if (( $1%2==0)); then
echo "$1 是偶数"
else
echo "$1 是奇数"
fi
fi