* testコマンド [#d7d611f8]

** 文字列比較 [#s503ecf6]
 "A" = "A"  
 "A" != "B"  
 -n "A" (文字列は空でない)
 -z ""  (文字列は空)

** 数値比較 [#cd94e02a]
 1 -eq 1
 2 -gt 1
 2 -ge 2
 1 -lt 2
 2 -le 2
 2 -ne 1

** ファイル評価 [#f17d3091]
 -f file
 -d dir
 -r file (読み込み可能)
 -w file (書き込み可能)
 -x file (実行可能)
 -s file (サイズ0以上)

** 論理演算子 [#x4001eff]
 1 -a 1
 0 -o 1

** 否定 [#w19ff52b]

 if [ ! -f /tmp/1.txt -a ! -f /tmp/2.txt ]; then
  echo "no 1.txt, no 2.txt"
 fi

** 参考 [#r60c0c21]
http://lagendra.s.kanazawa-u.ac.jp/ogurisu/manuals/sh-text/sh/node48.html

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS