2015-10-08 15:15:08 +00:00
|
|
|
.Dd 2015-10-08
|
2015-01-31 13:20:02 +00:00
|
|
|
.Dt TEST 1
|
2015-01-31 19:37:03 +00:00
|
|
|
.Os sbase
|
2015-01-30 21:52:01 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm test
|
2015-02-09 21:21:23 +00:00
|
|
|
.Nd evaluate expression
|
2015-01-30 21:52:01 +00:00
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm
|
2015-02-09 21:21:23 +00:00
|
|
|
.Ar expression
|
2015-01-30 21:52:01 +00:00
|
|
|
.Sh DESCRIPTION
|
2015-02-09 21:21:23 +00:00
|
|
|
.Nm
|
|
|
|
returns the status of the
|
|
|
|
.Ar expression .
|
2015-01-30 21:52:01 +00:00
|
|
|
.Sh OPTIONS
|
|
|
|
.Bl -tag -width Ds
|
2015-02-10 16:37:57 +00:00
|
|
|
.It ! Ar expression
|
2015-02-09 23:33:21 +00:00
|
|
|
invert
|
2015-02-09 21:21:23 +00:00
|
|
|
.Ar expression .
|
2015-02-09 23:33:21 +00:00
|
|
|
.It ( Fl e | Fl s ) Ar file
|
2015-02-09 21:21:23 +00:00
|
|
|
.Ar file
|
2015-02-09 23:33:21 +00:00
|
|
|
exists and has (any size
|
|
|
|
.Op Fl e
|
|
|
|
| non-zero size
|
|
|
|
.Op Fl s ) .
|
2015-02-10 16:37:57 +00:00
|
|
|
.It ( Fl f | Fl d | Fl p | Fl hL | Fl S | Fl b | Fl c ) Ar file
|
2015-02-09 21:21:23 +00:00
|
|
|
.Ar file
|
2015-02-09 23:33:21 +00:00
|
|
|
exists and is a
|
|
|
|
(regular file
|
|
|
|
.Op Fl f
|
|
|
|
| directory
|
|
|
|
.Op Fl d
|
|
|
|
| named pipe
|
|
|
|
.Op Fl p
|
|
|
|
| symbolic link
|
|
|
|
.Op Fl h | Fl L
|
|
|
|
| socket
|
|
|
|
.Op Fl S
|
|
|
|
| block special
|
|
|
|
.Op Fl b
|
|
|
|
| character special
|
|
|
|
.Op Fl c ) .
|
2015-02-10 16:37:57 +00:00
|
|
|
.It ( Fl k | Fl g | Fl u | Fl r | Fl w | Fl x ) Ar file
|
2015-02-09 21:21:23 +00:00
|
|
|
.Ar file
|
2015-02-09 23:33:21 +00:00
|
|
|
exists and has
|
|
|
|
.Xr ( sticky 1
|
|
|
|
.Op Fl k
|
|
|
|
|
|
|
|
|
.Xr setgid 2
|
|
|
|
.Op Fl g
|
|
|
|
|
|
|
|
|
.Xr setuid 4
|
|
|
|
.Op Fl u
|
|
|
|
|
|
|
|
|
.Xr read 4
|
|
|
|
.Op Fl r
|
|
|
|
|
|
|
|
|
.Xr write 2
|
|
|
|
.Op Fl w
|
|
|
|
|
|
|
|
|
.Xr execute 1
|
|
|
|
.Op Fl x )
|
|
|
|
permissions.
|
2015-02-09 21:21:23 +00:00
|
|
|
.It Fl t Ar fd
|
|
|
|
.Ar fd
|
2015-02-09 23:33:21 +00:00
|
|
|
as a file descriptor is associated with a terminal.
|
2015-02-09 21:21:23 +00:00
|
|
|
.It Ar string
|
|
|
|
True if
|
|
|
|
.Ar string
|
2015-02-09 23:33:21 +00:00
|
|
|
is not the null string.
|
2015-02-10 16:37:57 +00:00
|
|
|
.It ( Fl z | Fl n ) Ar string
|
2015-02-09 21:21:23 +00:00
|
|
|
True if
|
|
|
|
.Ar string
|
2015-02-09 23:33:21 +00:00
|
|
|
has (zero
|
|
|
|
.Op Fl z
|
|
|
|
| non-zero
|
|
|
|
.Op Fl n )
|
2015-02-09 21:21:23 +00:00
|
|
|
length.
|
2015-02-09 23:33:21 +00:00
|
|
|
.It Ar s1 Sy ( = | != ) Ar s2
|
2015-02-09 21:21:23 +00:00
|
|
|
True if strings
|
|
|
|
.Ar s1
|
|
|
|
and
|
|
|
|
.Ar s2
|
|
|
|
are
|
2015-02-09 23:33:21 +00:00
|
|
|
(identical
|
|
|
|
.Oo Sy = Oc
|
|
|
|
| different
|
|
|
|
.Oo Sy != Oc ) .
|
2015-02-10 16:37:57 +00:00
|
|
|
.It Ar n1 ( Fl eq | Fl ne | Fl gt | Fl ge | Fl le | Fl lt ) Ar n2
|
2015-02-09 21:21:23 +00:00
|
|
|
True if integers
|
|
|
|
.Ar n1
|
|
|
|
and
|
|
|
|
.Ar n2
|
2015-02-09 23:33:21 +00:00
|
|
|
are (=
|
|
|
|
.Op Fl eq
|
|
|
|
| !=
|
|
|
|
.Op Fl ne
|
|
|
|
| >
|
|
|
|
.Op Fl gt
|
|
|
|
| >=
|
|
|
|
.Op Fl ge
|
|
|
|
| <=
|
|
|
|
.Op Fl le
|
|
|
|
| <
|
|
|
|
.Op Fl lt ) .
|
2016-03-28 21:26:43 +00:00
|
|
|
.It Ar f1 ( Fl ef | Fl ot | Fl nt ) Ar f2
|
|
|
|
True if file
|
|
|
|
.Ar f1
|
|
|
|
(refer to the same inode as
|
|
|
|
.Op Fl ef
|
|
|
|
| has an older mtime than
|
|
|
|
.Op Fl ot
|
|
|
|
| has a newer mtime than
|
|
|
|
.Op Fl nt )
|
|
|
|
file
|
|
|
|
.Ar f2 .
|
2015-02-09 23:33:21 +00:00
|
|
|
.El
|
2015-02-09 21:21:23 +00:00
|
|
|
.Sh EXIT STATUS
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It 0
|
|
|
|
.Ar expression
|
|
|
|
is true.
|
|
|
|
.It 1
|
|
|
|
.Ar expression
|
|
|
|
is false.
|
|
|
|
.It > 1
|
|
|
|
An error occurred.
|
2015-01-30 21:52:01 +00:00
|
|
|
.El
|
2015-02-09 21:21:23 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr expr 1
|
|
|
|
.Sh STANDARDS
|
2015-03-17 22:35:11 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility is compliant with the
|
2015-03-27 16:22:48 +00:00
|
|
|
.St -p1003.1-2013
|
2015-03-17 22:35:11 +00:00
|
|
|
specification.
|