TEST(1)

πŸ“¦ version 0.12.0, in arch rolling

πŸ’… TEST(1) β€” the check-file-types-and-compare-values girlies ✨

ok so this is test from the General Commands Manual, and bestie, she is foundational. Every if you've ever written? She's behind it. Let's get into it 🫢


✨ NAME ✨

test β€” check file types and compare values. that's it. that's the whole job. and she does it flawlessly. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

test EXPRESSION
test
[ EXPRESSION ]
[ ]
[ OPTION

look at her four whole forms. main character energy fr fr πŸ’…


🌸 DESCRIPTION 🌸

Check file types and compare values.

like... yes. that's the vibe. she checks file types. she compares values. she does not elaborate. iconique πŸ’€


πŸŽ€ OPTIONS πŸŽ€

  • -h, --help β€” Print help. your little "what do i do" moment πŸ₯Ί
  • -V, --version β€” Print version. so you know exactly which girl you're dealing with πŸ’œ

πŸ”₯ EXTRA πŸ”₯

Exit with the status determined by EXPRESSION. that's her whole thing β€” she doesn't print stuff, she just sets exit status and dips. lowkey the most powerful move honestly.

An omitted EXPRESSION defaults to false. so test with nothing? false. [ ]? also false. yes bestie, that's real, no cap.

Otherwise, EXPRESSION is true or false and sets exit status. It is one of:

🧚 the logic-y ones

  • ( EXPRESSION ) β€” EXPRESSION is true. grouping!! but read the warning below about escaping, ok? πŸ™ˆ
  • ! EXPRESSION β€” EXPRESSION is false. the "not" girlie ✨
  • EXPRESSION1 -a EXPRESSION2 β€” both EXPRESSION1 and EXPRESSION2 are true. and!! both!! 🫢
  • EXPRESSION1 -o EXPRESSION2 β€” either EXPRESSION1 or EXPRESSION2 is true. or!! either!! 🌈

πŸ’– String operations:

  • -n STRING β€” the length of STRING is nonzero. she has ✨content✨
  • STRING β€” equivalent to -n STRING. so you can just say the thing. so chill of her.
  • -z STRING β€” the length of STRING is zero. empty. nothing. a void. πŸ’€
  • STRING1 = STRING2 β€” the strings are equal. twins!! πŸ‘―
  • STRING1 != STRING2 β€” the strings are not equal. not twins. 😭
  • STRING1 > STRING2 β€” STRING1 is greater than STRING2 in the current locale. yes, locale matters, it's giving "it depends" πŸ™ˆ
  • STRING1 < STRING2 β€” STRING1 is less than STRING2 in the current locale. same deal, locale girlie πŸ’…

🌈 Integer comparisons:

  • INTEGER1 -eq INTEGER2 β€” INTEGER1 is equal to INTEGER2
  • INTEGER1 -ge INTEGER2 β€” INTEGER1 is greater than or equal to INTEGER2
  • INTEGER1 -gt INTEGER2 β€” INTEGER1 is greater than INTEGER2
  • INTEGER1 -le INTEGER2 β€” INTEGER1 is less than or equal to INTEGER2
  • INTEGER1 -lt INTEGER2 β€” INTEGER1 is less than INTEGER2
  • INTEGER1 -ne INTEGER2 β€” INTEGER1 is not equal to INTEGER2

six of them. all accounted for. math ate. πŸ”₯

πŸ¦‹ File operations:

  • FILE1 -ef FILE2 β€” FILE1 and FILE2 have the same device and inode numbers. literally the same file, spiritually and technically πŸ’«
  • FILE1 -nt FILE2 β€” FILE1 is newer (modification date) than FILE2. fresh out the oven πŸ“
  • FILE1 -ot FILE2 β€” FILE1 is older than FILE2. vintage. antique. πŸ•°οΈ
  • -b FILE β€” FILE exists and is block special
  • -c FILE β€” FILE exists and is character special
  • -d FILE β€” FILE exists and is a directory. folder energy πŸ“
  • -e FILE β€” FILE exists. she's there. she's real. πŸ‘‘
  • -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. she has substance πŸ’…
  • -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

okay and here's the fine print, and bestie you need to hear it:

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. your shell is gonna eat them otherwise and you'll be so confused. πŸ™ˆ

INTEGER may also be -l STRING, which evaluates to the length of STRING. sneaky but valid ✨

NOTE: Binary -a and -o are inherently ambiguous. Use test EXPR1 && test EXPR2 or test EXPR1 || test EXPR2 instead. no cap, the binary ones are a trap β€” do the split version, future you will thank you 😭
NOTE: [ honors the --help and --version options, but test does not. test treats each of those as it treats any other nonempty STRING. so test --version is just... a string that exists. she said "not today" πŸ’€
NOTE: 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. iykyk β€” check your shell's docs, bestie 🧚

And one more genuinely cute detail: Errors are reported with the expression echoed back and a caret under the argument at fault whenever stderr is a terminal. like she's pointing at it. she's literally going "this one. right here." 🎯 anything else reading stderr gets the usual single-line message.


🌟 VERSION 🌟

v(uutils coreutils) 0.12.0


and that's the whole page, bestie!! πŸ’– slay, go write some conditionals β€” and remember, this was v(uutils coreutils) 0.12.0, dated 2026-09-17, from your General Commands Manual. mwah πŸ«Άβœ¨πŸŽ€πŸŒΈ

πŸ“¦ where this page comes from