TEST(1)
๐ Welcome to the test manual ๐
Okay bestie, this is the manual for test, which is TEST(1) in the User Commands section ๐ It's literally the tool that checks file types and compares values, and I'm obsessed with it. Let's go โจ
๐ธ NAME ๐ธ
test - check file types and compare values ๐ฆ
๐ง SYNOPSIS ๐ง
test EXPRESSION
test
[ EXPRESSION ]
[ ]
[ OPTION
๐ DESCRIPTION ๐
Okay so the whole point is to exit with the status determined by EXPRESSION ๐
It's giving exit codes, not printed output.
These two flags are the only ones you get, and they're giving main character energy:
--helpโ shows this help and exits ๐--versionโ outputs version info and exits โจ
If you leave out EXPRESSION entirely, it defaults to false. Otherwise the expression is either true or false, and that's what sets the exit status. Here's the whole menu ๐
( EXPRESSION )โEXPRESSIONis true! EXPRESSIONโEXPRESSIONis falseEXPRESSION1 -a EXPRESSION2โ bothEXPRESSION1andEXPRESSION2are trueEXPRESSION1 -o EXPRESSION2โ eitherEXPRESSION1orEXPRESSION2is true-n STRINGโ the length ofSTRINGis nonzeroSTRINGโ equivalent to-n STRING-z STRINGโ the length ofSTRINGis zeroSTRING1 = STRING2โ the strings are equalSTRING1 != STRING2โ the strings are not equalSTRING1 > STRING2โSTRING1is greater thanSTRING2in the current localeSTRING1 < STRING2โSTRING1is less thanSTRING2in the current localeINTEGER1 -eq INTEGER2โINTEGER1is equal toINTEGER2INTEGER1 -ge INTEGER2โINTEGER1is greater than or equal toINTEGER2INTEGER1 -gt INTEGER2โINTEGER1is greater thanINTEGER2INTEGER1 -le INTEGER2โINTEGER1is less than or equal toINTEGER2INTEGER1 -lt INTEGER2โINTEGER1is less thanINTEGER2INTEGER1 -ne INTEGER2โINTEGER1is not equal toINTEGER2FILE1 -ef FILE2โFILE1andFILE2have the same device and inode numbersFILE1 -nt FILE2โFILE1is newer (modification date) thanFILE2FILE1 -ot FILE2โFILE1is older thanFILE2-b FILEโFILEexists and is block special-c FILEโFILEexists and is character special-d FILEโFILEexists and is a directory-e FILEโFILEexists-f FILEโFILEexists and is a regular file-g FILEโFILEexists and is set-group-ID-G FILEโFILEexists and is owned by the effective group ID-h FILEโFILEexists and is a symbolic link (same as-L)-k FILEโFILEexists and has its sticky bit set-L FILEโFILEexists and is a symbolic link (same as-h)-N FILEโFILEexists and has been modified since it was last read-O FILEโFILEexists and is owned by the effective user ID-p FILEโFILEexists and is a named pipe-r FILEโFILEexists and the user has read access-s FILEโFILEexists and has a size greater than zero-S FILEโFILEexists and is a socket-t FDโ file descriptorFDis opened on a terminal-u FILEโFILEexists and its set-user-ID bit is set-w FILEโFILEexists and the user has write access-x FILEโFILEexists and the user has execute (or search) access
Quick vibe check on the file tests: except for -h and -L, all FILE-related tests dereference symbolic links ๐ Also, parentheses need to be escaped (e.g., by backslashes) for shells, so don't skip that ๐ซถ And INTEGER may also be -l STRING, which evaluates to the length of STRING ๐งฎ
โ ๏ธ Binary-aand-oare ambiguous, so it's giving chaos. Usetest EXPR1 && test EXPR2ortest EXPR1 || test EXPR2instead ๐ญ
๐[honors--helpand--version, buttesttreats them as STRINGs. Iykyk.
Your shell might have its own version of test and/or [, and that version usually takes over from the one described here ๐
Check your shell's documentation for the options it supports.
๐ AUTHOR ๐
Written by Kevin Braunsdorf and Matthew Bradburn ๐
๐ REPORTING BUGS ๐
GNU coreutils online help: <https://www.gnu.org/software/coreutils/> ๐ Report any translation bugs to <https://translationproject.org/team/> ๐
๐ฆ SEE ALSO ๐ฆ
access(2)โญ
Full documentation <https://www.gnu.org/software/coreutils/test> or available locally via: info '(coreutils) test invocation' ๐
Packaged by Debian (9.7-3) ๐ฆ Copyright ยฉ 2025 Free Software Foundation, Inc. ๐ 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.
Served fresh from GNU coreutils 9.7, June 2025, with love from your bestie ๐ซถ๐ โจ
๐ฆ where this page comes from
- debian trixie: coreutils 9.7-3 ยท GPL-3.0-or-later
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms