ファイル関連

  • -e {file1}
    • {file1} exists
  • -f {file1}
    • {file1}is normal
  • -d {file1}
    • {file1}is directory
  • -s {file1}
    • {file1}size is not empty
  • -L {file1}
    • {file1}is symbolic link
  • -h {file1}
    • {file1}is symbolic link
  • {file1} -ef {file2}
    • {file1} is {file2}‘S hard link

ファイル属性

  • -r {file1}
    • {file1} exists and readable
  • -w {file1}
    • {file1} exists and writable
  • -x {file1}
    • {file1} exists and executable
  • -O {file1}
    • {file1} file exists and is Owner is euid1
  • -G {file1}
    • {file1} exists and belongs group
  • -u {file1}
    • {file1} exists and is setuid
  • -g {file1}
    • {file1} exists and is setgid
  • -k
    • file exists and is sticky
  • {file1} -nt {file2}
    • {file1} is newer than {file2}
  • {file1} -ot {file2}
    • {file1} is older than {file2}

標準入出力

  • -t 0
    • std input is terminal
  • -t 1
    • std output is terminal
  • -t 2
    • std error is terminal
  • -t N
    • N’s file descriptor is terminal

文字列判定

  • {str1} = {str2}
    • {str1} equal {str2}
  • {str1} != {str2}
    • {str1} not equal {str2}
  • -z {str1}
    • {str1} size is 0
  • -n {str1}
    • {str1} size is not 0

整数判定

  • {num1} -eq {num2}
    • {num1} equal {num2}
  • {num1} -ne {num2}
    • {num1} not equal {num2}
  • {num1} -gt {num2}
    • {num1} greater then {num2}
  • {num1} -ge {num2}
    • {num1} greater or equal {num2}
  • {num1} -lt {num2}
    • {num1} less than {num2}
  • {num1} -le {num2}
    • {num1} less or equal {num2}

その他

  • -o {option}
    • {option} is defined
  • -v {variable}
    • {variable} is defined
  • ! {condition}
    • {condition} is FALSE
  • {condition1} -a {condition2}
    • {condition1} and {condition2} IS TRUE
  • {condition1} -o {condition2}
    • {condition1} or {condition2} IS TRUE
  • ({condition1})
    • prefer {condition1}
  • TRUE
    • usually TRUE
  • FALSE
    • usually FALSE

  1. 実効ユーザーID(euid)とはプログラムが動作するときの権限。プログラムを起動したユーザーのID(実ユーザーID、ruid)と等しいことが多い。 ↩︎