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       -N FILE
110              FILE exists and has been modified since it was last read
111
112       -O FILE
113              FILE exists and is owned by the effective user ID
114
115       -p FILE
116              FILE exists and is a named pipe
117
118       -r FILE
119              FILE exists and read permission is granted
120
121       -s FILE
122              FILE exists and has a size greater than zero
123
124       -S FILE
125              FILE exists and is a socket
126
127       -t FD  file descriptor FD is opened on a terminal
128
129       -u FILE
130              FILE exists and its set-user-ID bit is set
131
132       -w FILE
133              FILE exists and write permission is granted
134
135       -x FILE
136              FILE exists and execute (or search) permission is granted
137
138       Except for -h and  -L,  all  FILE-related  tests  dereference  symbolic
139       links.   Beware  that  parentheses  need  to be escaped (e.g., by back‐
140       slashes) for shells.  INTEGER may also be -l STRING, which evaluates to
141       the length of STRING.
142
143       NOTE:  Binary  -a  and -o are inherently ambiguous.  Use 'test EXPR1 &&
144       test EXPR2' or 'test EXPR1 || test EXPR2' instead.
145
146       NOTE: [ honors the --help and --version options,  but  test  does  not.
147       test treats each of those as it treats any other nonempty STRING.
148
149       NOTE:  your shell may have its own version of test and/or [, which usu‐
150       ally supersedes the version  described  here.   Please  refer  to  your
151       shell's documentation for details about the options it supports.
152

AUTHOR

154       Written by Kevin Braunsdorf and Matthew Bradburn.
155

REPORTING BUGS

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

SEE ALSO

167       Full documentation <https://www.gnu.org/software/coreutils/[>
168       or available locally via: info '(coreutils) test invocation'
169
170
171
172GNU coreutils 8.32                April 2020                           TEST(1)
Impressum