跳至主要内容

[BASH] Snippets

Number

String

Bash Strings Comparison Operators

OperatorDescription
[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.

See Also