最終更新:2013-07-23 (火) 13:42:06 (3923d)  

test
Top / test

ファイル形式のチェックや値の比較を行う

Bash/組み込みコマンド

  • オプション意味
    -eqtest num1 -eq num2num1 と num2 が等しければ真となる。
    -netest num1 -ne num2num1 と num2 が等しくなければ真となる。
    -lttest num1 -lt num2num1 が num2 より小ならば真となる。
    -letest num1 -le num2num1 が num2 以下ならば真となる。
    -gttest num1 -gt num2num1 が num2 より大ならば真となる。
    -getest num1 -ge num2num1 が num2 以上ならば真となる。
    =test 文字列1 = 文字列2
    !=test 文字列1 = 文字列2
    -nttest file1 -nt file2file1がfile2より新しいと真
    -ottest file1 -ot file2file1がfile2より古いと真
    -ztest -z stringstring の文字列長が 0 ならば真となる。
    -ntest -n stringstring の文字列長が 0 より大ならば真となる。
    -dtest -d filefile がディレクトリならば真となる。
    -ftest -f filefile が普通のファイルならば真となる。
    -stest -s filefile が 0 より大きいサイズならば真となる。
    -etest -e filefile が存在するならば真となる。
    -rtest -r filefile が読み取り可能ならば真となる。
    -wtest -w filefile が書き込み可能ならば真となる。
    -xtest -x filefile が実行可能ならば真となる。
    -atest 論理式1 -a 論理式2AND
    -atest 論理式1 -o 論理式2OR

参考

関連