[BASH] Snippets
Number
- ref: linux - How do I test if a variable is a number in Bash? - Stack Overflow
- ref: Checking if a Variable Is a Number in Bash | Baeldung on Linux
String
Bash Strings Comparison Operators
Operator | Description |
---|---|
[str1] == [str2] | The equality operator returns TRUE if both operands are equal. Used with the [[ command. |
[str1] != [str2] | The inequality operator returns TRUE if the specified operands are not equal. |
Sleep
#!/bin/bash
echo "Hi, I'm sleeping for 5 seconds..."
sleep 5
-
並非所有版本的 BASH 都支援時間單位如下, 使用前需確認.
語法:sleep NUMBER[SUFFIX]
SUFFIX 可以是:s for seconds (the default)
m for minutes.
h for hours.
d for days.