ã·ã§ã«ã®ifæã®æ¡ä»¶å¼
ãã£ãã®vimã¨åæ§ãèªåç¨ã®ã·ã§ã«ã¡ã¢
ã·ã§ã«ã®ifæã§ä½¿ããif [ -e filename ]; thenã¨ãã®
[]ã¯testã³ãã³ãã
æ¡ä»¶æã«ä½¿ãã奴ã¯ä»¥ä¸ã®éãã
ãã¡ã¤ã«å½¢å¼ã®ãã¹ã
å¼ | æå³ |
---|---|
-b file | file ãåå¨ãããããã¯ã¹ãã·ã£ã«ãã¡ã¤ã«ã§ããã°çã |
-c file | file ãåå¨ãããã£ã©ã¯ã¿ã¹ãã·ã£ã«ãã¡ã¤ã«ã§ããã°çã |
-d file | file ãåå¨ãããã£ã¬ã¯ããªã§ããã°çã |
-f file | file ãåå¨ããé常ãã¡ã¤ã« (regular file) ã§ããã°çã |
-h file ã¾ã㯠-L file | file ãåå¨ããã·ã³ããªãã¯ãªã³ã¯ã§ããã°çã |
-p file | file ãåå¨ããååä»ããã¤ã (named pipe) ã§ããã°çã |
-S file | file ãåå¨ããã½ã±ããã§ããã°çã |
-t [fd] | fd ã端æ«ã§ãªã¼ãã³ããã¦ããã°çã fd ãçç¥ãããå ´åã®ããã©ã«ãå¤ã¯ 1 (æ¨æºåºå)ã |
ãã¡ã¤ã«ã®ãã¼ããã·ã§ã³ã®ãã¹ã
å¼ | æå³ |
---|---|
-g file | file ãåå¨ããset GID ããã¦ããã°çã |
-k file | file ãåå¨ãã sticky ããããç«ã£ã¦ããã°çã |
-r file | file ãåå¨ããèªã¿åãå¯è½ã§ããã°çã |
-u file | file ãåå¨ãã set SUID ããã¦ããã°çã |
-w file | file ãåå¨ããæ¸ãè¾¼ã¿å¯è½ã§ããã°çã |
-x file | file ãåå¨ããå®è¡å¯è½ã§ããã°çã |
-O file | file ãåå¨ããç¾å¨ã®å®å¹ã¦ã¼ã¶ã¼ id ã«ããææã§ããã°çã |
-G file | file ãåå¨ããç¾å¨ã®å®å¹ã°ã«ã¼ã id ã«ããææã§ããã°çã |
ãã¡ã¤ã«ç¹æ§ã®ãã¹ã
å¼ | æå³ |
---|---|
-e file | file ãåå¨ããã°çã |
-s file | file ãåå¨ãããµã¤ãºã 0 ãã大ãããã°çã |
file1 -nt file2 | file1 ã file2 ãã (ä¿®æ£æå»ã§æ¯è¼ãã¦) æ°ãããã°çã |
file1 -ot file2 | file1 ã file2 ããå¤ããã°çã |
file1 -ef file2 | file1 㨠file2 ã®ããã¤ã¹çªå·ã¨ i-ãã¼ãçªå·ãå ±ã«çãããã°çã |
æååã®ãã¹ã
å¼ | æå³ |
---|---|
string ã¾ã㯠-n string | string ã®é·ãã 0 ãã大ãããã°çã |
-z string | string ã®é·ãã 0 ã§ããã°çã |
string1 = string2 | äºã¤ã®æååãçãããã°çã |
string1 != string2 | äºã¤ã®æååãçãããªããã°çã |
æ°å¤ã®ãã¹ã
- l stringã§ãstringã®é·ãã以ä¸ã®argã«å½ã¦ã¯ãããã
å¼ | æå³ |
---|---|
arg1 -eq arg2 | ã«çãã |
arg1 -ne arg2 | ã«çãããªã |
arg1 -lt arg2 | ããå°ãã |
arg1 -le arg2 | ããå°ãããçãã |
arg1 -gt arg2 | ãã大ãã |
arg1 -ge arg2 | ãã大ãããçãã |
ãã¹ãã®è«ççµå
å¼ | æå³ |
---|---|
! expr | expr ãå½ã§ããã°çã |
expr1 -a expr2 | expr1 㨠expr2 ã®ä¸¡æ¹ãçã§ããã°çã |
expr1 -o expr2 | expr1 ã expr2 ã®ã©ã¡ãããçã§ããã°çã |
ifæã¯è¯ã使ããã©æ¯åããããã®ã§ã
man testã§è§£èª¬ã
ã¨ãããä»åã®ã¡ã¢ã¯ããã®ã³ãã