[(1)
π NAME π
[ β the little bracket that checks file types and compares values. That's the whole job, bestie. No cap.
β¨ SYNOPSIS β¨
[ [-h|--help] [-V|--version]
πΈ DESCRIPTION πΈ
Okay so, [ checks file types and compares values. She's giving very much the same energy as test, just wearing a bracket costume and standing at the door of your shell script like a bouncer. π«Ά
π OPTIONS π
-h,--helpβ prints the help. iconic behavior, honestly. β¨-V,--versionβ prints the version. π
π₯ EXTRA π₯
She exits with the status determined by EXPRESSION. That's the vibe check β exit status is the answer.
An omitted EXPRESSION defaults to false. Otherwise, EXPRESSION is true or false and sets the exit status. It is one of:
( EXPRESSION )β EXPRESSION is true! EXPRESSIONβ EXPRESSION is falseEXPRESSION1 -a EXPRESSION2β both EXPRESSION1 and EXPRESSION2 are trueEXPRESSION1 -o EXPRESSION2β either EXPRESSION1 or EXPRESSION2 is true
π¦ String operations π¦
-n STRINGβ the length of STRING is nonzeroSTRINGβ equivalent to-n STRING-z STRINGβ 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 locale
π Integer comparisons π
INTEGER1 -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 INTEGER2
π File operations π
FILE1 -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-b FILEβ FILE exists and is block special-c FILEβ FILE exists and is character special-d FILEβ FILE exists and is a directory-e FILEβ FILE exists-f FILEβ FILE exists and is a regular file-g FILEβ FILE exists and is set-group-ID-G FILEβ FILE exists and is owned by the effective group ID-h FILEβ FILE exists and is a symbolic link (same as-L)-k FILEβ FILE exists and has its sticky bit set-L FILEβ FILE exists and is a symbolic link (same as-h)-N FILEβ FILE exists and has been modified since it was last read-O FILEβ FILE exists and is owned by the effective user ID-p FILEβ FILE exists and is a named pipe-r FILEβ FILE exists and read permission is granted-s FILEβ FILE exists and has a size greater than zero-S FILEβ FILE exists and is a socket-t FDβ file descriptor FD is opened on a terminal-u FILEβ FILE exists and its set-user-ID bit is set-w FILEβ FILE exists and write permission is granted-x FILEβ FILE exists and execute (or search) permission is granted
Except for -h and -L, all FILE-related tests dereference (follow) symbolic links. Beware that parentheses need to be escaped (e.g., by backslashes) for shells. INTEGER may also be -l STRING, which evaluates to the length of STRING.
NOTE: Binary-aand-oare inherently ambiguous. Usetest EXPR1 && test EXPR2ortest EXPR1 || test EXPR2instead. fr fr, don't do the ambiguous thing.
NOTE:[honors the--helpand--versionoptions, buttestdoes not.testtreats each of those as it treats any other nonempty STRING. not me getting caught out by that π
NOTE: your shell may have its own version oftestand/or[, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports. she's got her own rules, iykyk.
β VERSION β
v(uutils coreutils) 0.7.0
And that's the whole page, bestie β this was [ (uutils coreutils) 0.7.0, the General Commands Manual edition of [(1). Go forth and bracket responsibly. πβ¨π
π¦ where this page comes from
- epel 10: rust-coreutils-devel 0.7.0-10.el10_3 Β· MIT
- epel 10: uutils-coreutils 0.7.0-10.el10_3 Β· (MIT OR Apache-2.0) AND Unicode-DFS-2016 AND Zlib AND (0BSD OR MIT OR Apache-2.0) AND Apache-2.0 AND (Apache-2.0 OR Apache-2.0 WITH LLVM-exception) AND (Apache-2.0 OR GPL-2.0-only) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND BSD-2-Clause AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND BSD-3-Clause AND CC0-1.0 AND ISC AND MIT AND (MIT OR Zlib OR Apache-2.0) AND (MIT-0 OR Apache-2.0) AND Unicode-3.0 AND (Unlicense OR MIT)
- fedora 43: rust-coreutils-devel 0.7.0-12.fc43 Β· MIT
- fedora 43: uutils-coreutils 0.7.0-12.fc43 Β· (MIT OR Apache-2.0) AND Unicode-DFS-2016 AND Zlib AND (0BSD OR MIT OR Apache-2.0) AND Apache-2.0 AND (Apache-2.0 OR Apache-2.0 WITH LLVM-exception) AND (Apache-2.0 OR GPL-2.0-only) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND BSD-2-Clause AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND BSD-3-Clause AND CC0-1.0 AND ISC AND MIT AND (MIT OR Zlib OR Apache-2.0) AND (MIT-0 OR Apache-2.0) AND Unicode-3.0 AND (Unlicense OR MIT)
- fedora 44: rust-coreutils-devel 0.7.0-4.fc44 Β· MIT
- fedora 44: uutils-coreutils 0.7.0-4.fc44 Β· (MIT OR Apache-2.0) AND Unicode-DFS-2016 AND Zlib AND (0BSD OR MIT OR Apache-2.0) AND Apache-2.0 AND (Apache-2.0 OR Apache-2.0 WITH LLVM-exception) AND (Apache-2.0 OR GPL-2.0-only) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND BSD-2-Clause AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND BSD-3-Clause AND CC0-1.0 AND ISC AND MIT AND (MIT OR Zlib OR Apache-2.0) AND (MIT-0 OR Apache-2.0) AND Unicode-3.0 AND (Unlicense OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms