最終更新:2024-12-17 (火) 12:52:55 (205d)  

test
Top / test

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

  • test -n?

Bash/組み込みコマンド

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

参考

関連