kidoOooOoooOOom

ゲーム開発やってます

shellで条件式書く時のオプション

dとfを間違えていてハマったのでmemo。

オプション: 使用例: オプションの意味

  • -z: test -z string : string の文字列長が 0 ならば真となる。
  • -n: test -n string : string の文字列長が 0 より大ならば真となる。
  • -d: test -d file : file がディレクトリならば真となる。
  • -f: test -f file : file が普通のファイルならば真となる。
  • -s: test -s file : file が 0 より大きいサイズならば真となる。
  • -e: test -e file : file が存在するならば真となる。
  • -r: test -r file : file が読み取り可能ならば真となる。
  • -w: test -w file : file が書き込み可能ならば真となる。
  • -x: test -x file : file が実行可能ならば真となる。

参考URL
http://shellscript.sunone.me/if_and_test.html