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

14 lines
289 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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