> For the complete documentation index, see [llms.txt](https://brianwu.gitbook.io/brian/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brianwu.gitbook.io/brian/linux/ubuntu.md).

# Shell Script

參考資料:(<https://ithelp.ithome.com.tw/users/20005357/ironman/630>)

## ERROR:vi 的 上下左右 變成 ABDC

解決方法:(<https://blog.csdn.net/tmtongming/article/details/73162822>)

## 判斷式

**\*判斷式的中括號前後都要有空格**

```
-eq : 等於
-ne : 不等於
-gt : 大於
-ge : 大於或等於
-lt : 小於
-le : 小於或等於

# 如果判斷式為真，就執行 do something 1
if [ 判斷式 ]; then
  do something 1
fi

# 如果判斷式為真，就執行 do something 1, 否則就執行 do something 2
if [ 判斷式 ]; then
  do something 1
else
  do something 2

# 如果判斷式為真，就執行 do something 1, 為假往下執行看 判斷式2 是否為真
# 為真就執行 do something 2, 否則就執行 do something 3
if [ 判斷式 ]; then
  do something 1
elif [ 判斷式2 ]; then
  do something 2
else
  do something 3
fi
```
