www.delorie.com/gnu/docs/sh-utils/sh-utils_19.html   search  
 
Buy GNU books!


GNU shell utilities

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3 test: Check file types and compare values

test returns a status of 0 (true) or 1 (false) depending on the evaluation of the conditional expression expr. Each part of the expression must be a separate argument.

test has file status checks, string operators, and numeric comparison operators.

Because most shells have a built-in command by the same name, using the unadorned command name in a script or interactively may get you different functionality than that described here.

Besides the options below, test accepts a lone `--help' or `--version'. See section 2. Common options. A single non-option argument is also allowed: test returns true if the argument is not null.

5.3.1 File type tests  -[bcdfhLpSt]
5.3.2 Access permission tests  -[gkruwxOG]
5.3.3 File characteristics tests  -e -s -nt -ot -ef
5.3.4 String tests  -z -n = !=
5.3.5 Numeric tests  -eq -ne -lt -le -gt -ge
5.3.6 Connectives for test  ! -a -o


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003