TEST(1)
π TEST(1) β the test manual, bestie edition π
okay so this is the manual page for test (it lives in the User Commands corner of your system), and honestly? it's the little gremlin that powers every single if you've ever written in a shell script. no cap. let's get into it. π«Ά
β¨ NAME β¨
test β check file types and compare values
πΈ SYNOPSIS πΈ
test EXPRESSION
test
[ EXPRESSION ]
[ ]
[ OPTION
π DESCRIPTION π
The whole entire job: exit with the status determined by EXPRESSION. that's it. that's the gig. π
--help β display this help and exit
--version β output version information and exit
If you just... don't give it an EXPRESSION at all (an omitted EXPRESSION), it defaults to false. quiet quitting, honestly. π Otherwise EXPRESSION evaluates to true or false and that sets the exit status. It's one of these:
( EXPRESSION )β EXPRESSION is true! EXPRESSIONβ EXPRESSION is falseEXPRESSION1 -a EXPRESSION2β both EXPRESSION1 and EXPRESSION2 are trueEXPRESSION1 -o EXPRESSION2β either EXPRESSION1 or EXPRESSION2 is true-nSTRING β the length of STRING is nonzero- STRING β literally equivalent to
-n STRING -zSTRING β the length of STRING is zeroSTRING1 = STRING2β the strings are equalSTRING1 != STRING2β the strings are not equalSTRING1 > STRING2β STRING1 is greater than STRING2 in the current localeSTRING1 < STRING2β STRING1 is less than STRING2 in the current localeINTEGER1 -eq INTEGER2β INTEGER1 is equal to INTEGER2INTEGER1 -ge INTEGER2β INTEGER1 is greater than or equal to INTEGER2INTEGER1 -gt INTEGER2β INTEGER1 is greater than INTEGER2INTEGER1 -le INTEGER2β INTEGER1 is less than or equal to INTEGER2INTEGER1 -lt INTEGER2β INTEGER1 is less than INTEGER2INTEGER1 -ne INTEGER2β INTEGER1 is not equal to INTEGER2FILE1 -ef FILE2β FILE1 and FILE2 have the same device and inode numbersFILE1 -nt FILE2β FILE1 is newer (modification date) than FILE2FILE1 -ot FILE2β FILE1 is older than FILE2-bFILE β FILE exists and is block special-cFILE β FILE exists and is character special-dFILE β FILE exists and is a directory-eFILE β FILE exists-fFILE β FILE exists and is a regular file-gFILE β FILE exists and is set-group-ID-GFILE β FILE exists and is owned by the effective group ID-hFILE β FILE exists and is a symbolic link (same as-L)-kFILE β FILE exists and has its sticky bit set-LFILE β FILE exists and is a symbolic link (same as-h)-NFILE β FILE exists and has been modified since it was last read-OFILE β FILE exists and is owned by the effective user ID-pFILE β FILE exists and is a named pipe-rFILE β FILE exists and the user has read access-sFILE β FILE exists and has a size greater than zero-SFILE β FILE exists and is a socket-tFD β file descriptor FD is opened on a terminal-uFILE β FILE exists and its set-user-ID bit is set-wFILE β FILE exists and the user has write access-xFILE β FILE exists and the user has execute (or search) access
and now the fine print, bestie, because there IS fine print π§:
Except for -h and -L, all FILE-related tests dereference symbolic links. the way that only those two don't follow the link... iconic of them honestly.
Beware that parentheses need to be escaped (e.g., by backslashes) for shells. yes really. your shell will eat them otherwise. π Also heads up: INTEGER may also be -l STRING, which evaluates to the length of STRING.
careful bestie π¨ Binary-aand-oare ambiguous. Use'test EXPR1 && test EXPR2'or'test EXPR1 || test EXPR2'instead.
'[' honors --help and --version, but 'test' treats them as STRINGs. two siblings, two completely different personalities. π
Your shell may have its own version of test and/or [, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports. (fr fr, go check, don't come for this page's neck. π)
π AUTHOR π
Written by Kevin Braunsdorf and Matthew Bradburn. legends, genuinely. π«Ά
π REPORTING BUGS π
- Report bugs to: bug-coreutils@gnu.org
- GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
- General help using GNU software: <https://www.gnu.org/gethelp/>
- Report any translation bugs to: <https://translationproject.org/team/>
π₯ SEE ALSO π₯
access(2)- Full documentation at <https://www.gnu.org/software/coreutils/test>
- or available locally via:
info '(coreutils) test invocation'
and that's the whole page, bestie, you ate. π okay so packing it up: this page was Packaged by Ubuntu (9.10-1ubuntu2), the copyright lives with Copyright Β© 2026 Free Software Foundation, Inc., and it's under License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. (gnu said no warranty and they meant it π )
this whole thing rode in with GNU coreutils 9.10, stamped August 2026, and yes it's the TEST(1) page from the User Commands chapter. mwah. πβ¨
π¦ where this page comes from
- ubuntu stonking: gnu-coreutils 9.10-1ubuntu2 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms