[go: up one dir, main page]

File: test.1

package info (click to toggle)
shellutils 1.16-6.3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 3,284 kB
  • ctags: 2,158
  • sloc: ansic: 22,599; yacc: 1,034; sh: 612; makefile: 368; perl: 239; sed: 93
file content (167 lines) | stat: -rw-r--r-- 3,684 bytes parent folder | download | duplicates (2)
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
.TH TEST 1 "GNU Shell Utilities" "FSF" \" -*- nroff -*-
.SH NAME
test \- check file types and compare values
.SH SYNOPSIS
.B test
[expr]
.br
.B test
{\-\-help,\-\-version}
.SH DESCRIPTION
This documentation is no longer being maintained and may be inaccurate
or incomplete.  The Texinfo documentation is now the authoritative source.
.PP
This manual page
documents the GNU version of
.BR test .
Note that most shells have a built-in command by the same name and
with similar functionality.
.PP
.B test
returns a status of 0 (true) or 1 (false) depending on
the evaluation of
the conditional expression
.IR expr .
Expressions may be unary or binary.  Unary
expressions are often used to examine the status of a file.  There
are string operators
and numeric comparison operators as well.

.PD 0
.TP
.B \-b \fIfile\fP
True if \fIfile\fP exists and is block special.
.TP
.B \-c \fIfile\fP
True if \fIfile\fP exists and is character special.
.TP
.B \-d \fIfile\fP
True if \fIfile\fP exists and is a directory.
.TP
.B \-e \fIfile\fP
True if \fIfile\fP exists
.TP
.B \-f \fIfile\fP
True if \fIfile\fP exists and is a regular file.
.TP
.B \-g \fIfile\fP
True if \fIfile\fP exists and is set-group-id.
.TP
.B \-k \fIfile\fP
True if \fIfile\fP has its ``sticky'' bit set.
.TP
.B \-L \fIfile\fP
True if \fIfile\fP exists and is a symbolic link.
.TP
.B \-p \fIfile\fP
True if \fIfile\fP exists and is a named pipe.
.TP
.B \-r \fIfile\fP
True if \fIfile\fP exists and is readable.
.TP
.B \-s \fIfile\fP
True if \fIfile\fP exists and has a size greater than zero.
.TP
.B \-S \fIfile\fP
True if \fIfile\fP exists and is a socket.
.TP
.B \-t [\fIfd\fP]
True if
.I fd
is opened on a terminal.  If
.I fd
is omitted, it defaults to 1 (standard output).
.TP
.B \-u \fIfile\fP
True if \fIfile\fP exists and its set-user-id bit is set.
.TP
.B \-w \fIfile\fP
True if \fIfile\fP exists and is writable.
.TP
.B \-x \fIfile\fP
True if \fIfile\fP exists and is executable.
.TP
.B \-O \fIfile\fP
True if \fIfile\fP exists and is owned by the effective user id.
.TP
.B \-G \fIfile\fP
True if \fIfile\fP exists and is owned by the effective group id.
.TP
\fIfile1\fP \-\fBnt\fP \fIfile2\fP
True if \fIfile1\fP is newer (according to
modification date) than \fIfile2\fP.
.TP
\fIfile1\fP \-\fBot\fP \fIfile2\fP
True if \fIfile1\fP is older than file2.
.TP
\fIfile1\fP \fB\-ef\fP \fIfile2\fP
True if \fIfile1\fP and \fIfile2\fP have the same device and
inode numbers.
.TP
.B \-z \fIstring\fP
True if the length of \fIstring\fP is zero.
.TP
.B \-n \fIstring\fP
.TP
\fIstring\fP
True if the length of
.I string
is non-zero.
.TP
\fIstring1\fP \fB=\fP \fIstring2\fP
True if the strings are equal.
.TP
\fIstring1\fP \fB!=\fP \fIstring2\fP
True if the strings are not equal.
.TP
.B ! \fIexpr\fP
True if
.I expr
is false.
.TP
\fIexpr1\fP \-\fBa\fP \fIexpr2\fP
True if both
.I expr1
and
.I expr2
are true.
.TP
\fIexpr1\fP \-\fBo\fP \fIexpr2\fP
True if either
.I expr1
or
.I expr2
is true.
.TP
.I arg1 \fBOP\fP arg2
.SM
.B OP
is one of
.BR \-eq ,
.BR \-ne ,
.BR \-lt ,
.BR \-le ,
.BR \-gt ,
or
.BR \-ge .
These arithmetic binary operators return true if \fIarg1\fP
is equal, not-equal, less-than, less-than-or-equal,
greater-than, or greater-than-or-equal than \fIarg2\fP,
respectively.
.I arg1
and
.I arg2
may be positive integers, negative integers, or the special
expression \fB\-l\fP \fIstring\fP, which evaluates to the
length of 
.IR string .
.SS OPTIONS
When GNU
.B test
is invoked with exactly one argument, the following options are recognized:
.TP
.I "\-\-help"
Print a usage message on standard output and exit successfully.
.TP
.I "\-\-version"
Print version information on standard output then exit successfully.