1TEST(1)                          User Commands                         TEST(1)
2
3
4

NAME

6       test - check file types and compare values
7

SYNOPSIS

9       test EXPRESSION
10       test
11       [ EXPRESSION ]
12       [ ]
13       [ OPTION
14

DESCRIPTION

16       Exit with the status determined by EXPRESSION.
17
18       --help display this help and exit
19
20       --version
21              output version information and exit
22
23       An omitted EXPRESSION defaults to false.  Otherwise, EXPRESSION is true
24       or false and sets exit status.  It is one of:
25
26       ( EXPRESSION )
27              EXPRESSION is true
28
29       ! EXPRESSION
30              EXPRESSION is false
31
32       EXPRESSION1 -a EXPRESSION2
33              both EXPRESSION1 and EXPRESSION2 are true
34
35       EXPRESSION1 -o EXPRESSION2
36              either EXPRESSION1 or EXPRESSION2 is true
37
38       -n STRING
39              the length of STRING is nonzero
40
41       STRING equivalent to -n STRING
42
43       -z STRING
44              the length of STRING is zero
45
46       STRING1 = STRING2
47              the strings are equal
48
49       STRING1 != STRING2
50              the strings are not equal
51
52       INTEGER1 -eq INTEGER2
53              INTEGER1 is equal to INTEGER2
54
55       INTEGER1 -ge INTEGER2
56              INTEGER1 is greater than or equal to INTEGER2
57
58       INTEGER1 -gt INTEGER2
59              INTEGER1 is greater than INTEGER2
60
61       INTEGER1 -le INTEGER2
62              INTEGER1 is less than or equal to INTEGER2
63
64       INTEGER1 -lt INTEGER2
65              INTEGER1 is less than INTEGER2
66
67       INTEGER1 -ne INTEGER2
68              INTEGER1 is not equal to INTEGER2
69
70       FILE1 -ef FILE2
71              FILE1 and FILE2 have the same device and inode numbers
72
73       FILE1 -nt FILE2
74              FILE1 is newer (modification date) than FILE2
75
76       FILE1 -ot FILE2
77              FILE1 is older than FILE2
78
79       -b FILE
80              FILE exists and is block special
81
82       -c FILE
83              FILE exists and is character special
84
85       -d FILE
86              FILE exists and is a directory
87
88       -e FILE
89              FILE exists
90
91       -f FILE
92              FILE exists and is a regular file
93
94       -g FILE
95              FILE exists and is set-group-ID
96
97       -G FILE
98              FILE exists and is owned by the effective group ID
99
100       -h FILE
101              FILE exists and is a symbolic link (same as -L)
102
103       -k FILE
104              FILE exists and has its sticky bit set
105
106       -L FILE
107              FILE exists and is a symbolic link (same as -h)
108
109       -O FILE
110              FILE exists and is owned by the effective user ID
111
112       -p FILE
113              FILE exists and is a named pipe
114
115       -r FILE
116              FILE exists and read permission is granted
117
118       -s FILE
119              FILE exists and has a size greater than zero
120
121       -S FILE
122              FILE exists and is a socket
123
124       -t FD  file descriptor FD is opened on a terminal
125
126       -u FILE
127              FILE exists and its set-user-ID bit is set
128
129       -w FILE
130              FILE exists and write permission is granted
131
132       -x FILE
133              FILE exists and execute (or search) permission is granted
134
135       Except for -h and  -L,  all  FILE-related  tests  dereference  symbolic
136       links.   Beware  that  parentheses  need  to be escaped (e.g., by back‐
137       slashes) for shells.  INTEGER may also be -l STRING, which evaluates to
138       the length of STRING.
139
140       NOTE:  Binary  -a  and -o are inherently ambiguous.  Use 'test EXPR1 &&
141       test EXPR2' or 'test EXPR1 || test EXPR2' instead.
142
143       NOTE: [ honors the --help and --version options,  but  test  does  not.
144       test treats each of those as it treats any other nonempty STRING.
145
146       NOTE:  your shell may have its own version of test and/or [, which usu‐
147       ally supersedes the version  described  here.   Please  refer  to  your
148       shell's documentation for details about the options it supports.
149

AUTHOR

151       Written by Kevin Braunsdorf and Matthew Bradburn.
152

REPORTING BUGS

154       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
155       Report [ translation bugs to <https://translationproject.org/team/>
156
158       Copyright  ©  2018  Free Software Foundation, Inc.  License GPLv3+: GNU
159       GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
160       This is free software: you are free  to  change  and  redistribute  it.
161       There is NO WARRANTY, to the extent permitted by law.
162

SEE ALSO

164       Full documentation at: <https://www.gnu.org/software/coreutils/[>
165       or available locally via: info '(coreutils) test invocation'
166
167
168
169GNU coreutils 8.30                 July 2018                           TEST(1)
Impressum