File: test.1

package info (click to toggle)
manpages-ja 0.5.0.0.20120606-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 25,964 kB
  • sloc: perl: 161; makefile: 116
file content (189 lines) | stat: -rw-r--r-- 5,526 bytes parent folder | download | duplicates (6)
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
180
181
182
183
184
185
186
187
188
189
.\" You may copy, distribute and modify under the terms of the LDP General
.\" Public License as specified in the LICENSE file that comes with the
.\" gnumaniak distribution
.\"
.\" The author kindly requests that no comments regarding the "better"
.\" suitability or up-to-date notices of any info documentation alternative
.\" is added without contacting him first.
.\"
.\" (C) 1999-2002 Ragnar Hojland Espinosa <ragnar@ragnar-hojland.com>
.\"
.\"     GNU test man page
.\"     man pages are NOT obsolete!
.\"     <ragnar@ragnar-hojland.com>
.\"
.\" Japanese Version Copyright (c) 2000 NAKANO Takeo all rights reserved.
.\" Translated Sun 12 Mar 2000 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
.\" 
.TH test 1 "18 June 2002" "GNU Shell Utilities 2.1"
.SH 名前
test \- ファイル形式のチェックや値の比較を行う
.SH 書式
.BI "test [" expr ]
.sp
.B test [\-\-help] [\-\-version]
.SH 説明
.B test
は条件式
.IR expr
を評価した結果によって、 0 (真) または 1 (偽)
を終了ステータスとして返す。
.PP
式の各部分はそれぞれ分離された引数でなければならない。
式は単項式あるいは二項式である。
.B test
はファイルのステータス調査、文字列操作、数値の比較演算を行うことができる。
.PP
ほとんどのシェルには同名の組み込みコマンドがあるので、
単に `test' として実行すると、
ここで記述されたものとは異なった機能のものが実行されるだろう。
.SS ファイル形式のテスト
.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 \-f \fIfile\fP
\fIfile\fP が存在し、通常ファイル (regular file) であれば真。
.TP
.B \-h \fIfile\fP
.TP
.B \-L \fIfile\fP
\fIfile\fP が存在し、シンボリックリンクであれば真。
.TP
.B \-p \fIfile\fP
\fIfile\fP が存在し、名前付きパイプ (named pipe) であれば真。
.TP
.B \-S \fIfile\fP
\fIfile\fP が存在し、ソケットであれば真。
.TP
.B \-t [\fIfd\fP]
.I fd
が端末でオープンされていれば真。
.I fd
が省略された場合のデフォルト値は 1 (標準出力)。

.SS ファイルのパーミッションのテスト
.TP
.B \-g \fIfile\fP
\fIfile\fP が存在し、set GID されていれば真。
.TP
.B \-k \fIfile\fP
\fIfile\fP が存在し、 sticky ビットが立っていれば真。
.TP
.B \-r \fIfile\fP
\fIfile\fP が存在し、読み取り可能であれば真。
.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 による所有であれば真。

.SS ファイル特性のテスト
.TP
.B \-e \fIfile\fP
\fIfile\fP が存在すれば真。
.TP
.B \-s \fIfile\fP
\fIfile\fP が存在し、サイズが 0 より大きければ真。
.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-ノード番号が共に等しければ真。

.SS 文字列のテスト
.TP
.B \fIstring\fP
.TP
.B \-n \fIstring\fP
.I string
の長さが 0 より大きければ真。
.TP
.B \-z \fIstring\fP
\fIstring\fP の長さが 0 であれば真。
.TP
\fIstring1\fP \fB=\fP \fIstring2\fP
二つの文字列が等しければ真。
.TP
\fIstring1\fP \fB!=\fP \fIstring2\fP
二つの文字列が等しくなければ真。

.SS 数値のテスト
.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 という特殊な式を指定することもでき、
この場合は
.I string
の長さとなる。

.SS テストの論理結合
.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
のどちらかが真であれば真。
.PD 1
.SH オプション
GNU
.B test
が引数一つだけで起動された場合には、
以下のオプションが認識される:
.TP
.B "\-\-help"
標準出力に使用方法のメッセージを出力して正常終了する。
.TP
.B "\-\-version"
標準出力にバージョン情報を出力して正常終了する。
.SH 注意
プログラムのバグについては bug-sh-utils@gnu.org に報告してください。
ページの更新は Ragnar Hojland Espinosa <ragnar@ragnar-hojland.com> が行っています。