1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
.\" This file documents the GNU shell utilities.
.\"
.\" Copyright (C) 1994 Free Software Foundation, Inc.
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of
.\" this manual under the conditions for verbatim copying, provided that
.\" the entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Permission is granted to copy and distribute translations of this
.\" manual into another language, under the above conditions for modified
.\" versions, except that this permission notice may be stated in a
.\" translation approved by the Foundation.
.\"
.\" Japanese Version Copyright (c) 1997 NAKANO Takeo, all rights reserved.
.\" Translated Thu May 27 1997 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
.\"
.TH TEST 1 "GNU Shell Utilities" "FSF" \" -*- nroff -*-
.SH 名前
test \- ファイルの形式のチェックや値の比較を行う
.SH 書式
.B test
[expr]
.br
.B test
{\-\-help,\-\-version}
.SH 説明
この文書はもうメンテナンスされていないので、不正確・不完全
な可能性がある。現在は texinfo 文書が正式な情報となっている。
.PP
このマニュアルページは GNU 版
.BR test
について記述したものである。
ほとんどのシェルには同じ名前と同様の機能を持った組み込みコマンドが
あることに注意。
.PP
.B test
は条件式
.IR expr
を評価した結果によって、 0(真)または 1(偽)を終了ステータス
として返す。
式は単項式あるいは二項式である。単項式は通常ファイルのステータスを調べ
るために用いられる。文字列に対する演算子や数値を比較する演算子もある。
.PD 0
.TP
.B \-b \fIfile\fP
\fIfile\fP が存在し、ブロックスペシャルファイルであれば真。
.TP
.B \-c \fIfile\fP
\fIfile\fP が存在し、キャラクタスペシャルファイルであれば真。
.TP
.B \-d \fIfile\fP
\fIfile\fP が存在し、ディレクトリであれば真。
.TP
.B \-e \fIfile\fP
\fIfile\fP が存在すれば真。
.TP
.B \-f \fIfile\fP
\fIfile\fP が存在し、通常のファイルであれば真。
.TP
.B \-g \fIfile\fP
\fIfile\fP が存在し、set GID されていれば真。
.TP
.B \-k \fIfile\fP
\fIfile\fP が存在し、 sticky ビットが立っていれば真。
.TP
.B \-L \fIfile\fP
\fIfile\fP が存在し、シンボリックリンクであれば真。
.TP
.B \-p \fIfile\fP
\fIfile\fP が存在し、名前付きパイプ(named pipe)であれば真。
.TP
.B \-r \fIfile\fP
\fIfile\fP が存在し、読み取り可能であれば真。
.TP
.B \-s \fIfile\fP
\fIfile\fP が存在し、サイズが 0 より大きければ真。
.TP
.B \-S \fIfile\fP
\fIfile\fP が存在し、ソケットであれば真。
.TP
.B \-t [\fIfd\fP]
.I fd
が端末でオープンされていれば真。
.I fd
が省略された場合のデフォルト値は 1(標準出力)。
.TP
.B \-u \fIfile\fP
\fIfile\fP が存在し、 set SUID されていれば真。
.TP
.B \-w \fIfile\fP
\fIfile\fP が存在し、書き込み可能であれば真。
.TP
.B \-x \fIfile\fP
\fIfile\fP が存在し、実行可能であれば真。
.TP
.B \-O \fIfile\fP
\fIfile\fP が存在し、実効ユーザー ID による所有であれば真。
.TP
.B \-G \fIfile\fP
\fIfile\fP が存在し、実効グループ ID による所有であれば真。
.TP
\fIfile1\fP \-\fBnt\fP \fIfile2\fP
\fIfile1\fP が \fIfile2\fP より(修正時刻で比較して)新しければ真。
.TP
\fIfile1\fP \-\fBot\fP \fIfile2\fP
\fIfile1\fP が \fIfile2\fP より古ければ真。
.TP
\fIfile1\fP \fB\-ef\fP \fIfile2\fP
\fIfile1\fP と \fIfile2\fP のデバイス番号と i-ノード番号が共に等しけれ
ば真。
.TP
.B \-z \fIstring\fP
\fIstring\fP の長さが 0 であれば真。
.TP
.B \-n \fIstring\fP
.TP
.I string
の長さが 0 より大きければ真。
.TP
\fIstring1\fP \fB=\fP \fIstring2\fP
二つの文字列が等しければ真。
.TP
\fIstring1\fP \fB!=\fP \fIstring2\fP
二つの文字列が等しくなければ真。
.TP
.B ! \fIexpr\fP
.I expr
が偽であれば真。
.TP
\fIexpr1\fP \-\fBa\fP \fIexpr2\fP
.I expr1
と
.I expr2
の両方が真であれば真。
.TP
\fIexpr1\fP \-\fBo\fP \fIexpr2\fP
.I expr1
か
.I expr2
のどちらかが真であれば真。
.TP
.I arg1 \fBOP\fP arg2
.SM
.B OP
は
.BR \-eq 、
.BR \-ne 、
.BR \-lt 、
.BR \-le 、
.BR \-gt 、
.BR \-ge
のいずれか。
これらの代数比較演算子は、それぞれ \fIarg1\fP が \fIarg2\fP(に等しい、
に等しくない、より小さい、より小さいか等しい、より大きい、より大きいか
等しい)条件を満たせば真。
.I arg1
および
.I arg2
は正の整数、負の整数をとることができる。また \fB\-l\fP \fIstring\fP
という特殊な式を指定することもでき、この場合は
.IR string
の長さとなる。
.SS オプション
GNU
.B test
が引き数一つで実行されたときに限り、以下のオプションが認識される:
.TP
.I "\-\-help"
使い方に関するメッセージを標準出力に表示し、実行成功を返して終了する。
.TP
.I "\-\-version"
バージョン情報を標準出力に表示し、実行成功を返して終了する。
|