14 lines
289 B
Bash
14 lines
289 B
Bash
|
#!/bin/bash
|
|||
|
|
|||
|
# 编写一个Shell脚本,接受一个数字作为参数,并判断该数字是奇数还是偶数。
|
|||
|
|
|||
|
if [ $# -ne 1 ]; then
|
|||
|
echo "参数个数不正确"
|
|||
|
exit 1
|
|||
|
else
|
|||
|
if (( $1%2==0)); then
|
|||
|
echo "$1 是偶数"
|
|||
|
else
|
|||
|
echo "$1 是奇数"
|
|||
|
fi
|
|||
|
fi
|