test
Return true or false by performing tests. toybox
On Linux 1 Sigma rule name it
Linux
Return true or false by performing tests. No arguments is false, one argument is true if not empty string. --- Tests with a single argument (after the option): --- Tests with one argument on each side of an operator:
test [-bcdefghkLprSsuwx PATH] [-nz STRING] [-t FD] [X ?? Y]
Show 28 options
-b PATHblock device-f PATHregular file-p PATHfifo-u PATHsetuid bit-c PATHchar device-g PATHsetgid-r PATHreadable-w PATHwritable-d PATHdirectory-h PATHsymlink-S PATHsocket-x PATHexecutable-e PATHexists-L PATHsymlink-s PATHnonzero size-k PATHsticky bit-n STRINGnonzero size-z STRINGzero size-t FDa TTY = are identical != differ =~ string matches regex < first is lower > first higher-eqequal-gtfirst > second-ltfirst < second-nenot equal-gefirst >= second-lefirst <= second-otOlder mtime-ntNewer mtime-efsame dev/inode ! EXPR not (swap true/false) EXPR -a EXPR and (are both true) ( EXPR ) evaluate this first EXPR -o EXPR or (is either true)Several platforms
Check file types and compare values. Returns 0 if the condition evaluates to true, 1 if it evaluates to false.
Test if a given variable is equal to a given string
test "$MY_VAR" = "/bin/zsh"IdentifyIf A is true, then do B, or C in the case of an error (notice that C may run even if A fails)
test condition && echo "true" || echo "false"IdentifyUse test in a conditional statement
if test -f "path/to/file"; then echo "File exists"; else echo "File does not exist"; fiIdentify-fregular file toyboxDisplay help
help testIdentify