# 检查数字是偶数还是奇数

在shell中检查数字是偶数还是奇数，其实就是取模，查看取模以后的余数是0还是1

```bash
#Bash Script to check whether a number is even or odd
read -p "Enter a number: " number
if [ $((number%2)) -eq 0 ]
then
  echo "Number is even."
else
  echo "Number is odd."
fi
```

这种取模方式也适合hash，也就是均布到指定数量的桶中。

## 参考

* [Bash Shell Script to check whether a number is even or odd](https://www.tutorialsandyou.com/bash-shell-scripting/even-odd-14.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/develop/shell/bash/check_number_even_or_odd.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
