Flashnux

GNU/Linux man pages

Livre :
Expressions régulières,
Syntaxe et mise en oeuvre :

ISBN : 978-2-7460-9712-4
EAN : 9782746097124
(Editions ENI)

GNU/Linux

RedHat 5.2

(Apollo)

test(1)


TEST

TEST

NAME
SYNOPSIS
DESCRIPTION

NAME

test − check file types and compare values

SYNOPSIS

test [expr]
test
{−−help,−−version}

DESCRIPTION

This documentation is no longer being maintained and may be inaccurate or incomplete. The Texinfo documentation is now the authoritative source.

This manual page documents the GNU version of test. Note that most shells have a built-in command by the same name and with similar functionality.

test returns a status of 0 (true) or 1 (false) depending on the evaluation of the conditional expression expr. Expressions may be unary or binary. Unary expressions are often used to examine the status of a file. There are string operators and numeric comparison operators as well.
−b
file

True if file exists and is block special.

−c file

True if file exists and is character special.

−d file

True if file exists and is a directory.

−e file

True if file exists

−f file

True if file exists and is a regular file.

−g file

True if file exists and is set-group-id.

−k file

True if file has its ’’sticky’’ bit set.

−L file

True if file exists and is a symbolic link.

−p file

True if file exists and is a named pipe.

−r file

True if file exists and is readable.

−s file

True if file exists and has a size greater than zero.

−S file

True if file exists and is a socket.

−t [fd]

True if fd is opened on a terminal. If fd is omitted, it defaults to 1 (standard output).

−u file

True if file exists and its set-user-id bit is set.

−w file

True if file exists and is writable.

−x file

True if file exists and is executable.

−O file

True if file exists and is owned by the effective user id.

−G file

True if file exists and is owned by the effective group id.

file1nt file2

True if file1 is newer (according to modification date) than file2.

file1ot file2

True if file1 is older than file2.

file1 −ef file2

True if file1 and file2 have the same device and inode numbers.

−z string

True if the length of string is zero.

−n string

string

True if the length of string is non-zero.

string1 = string2

True if the strings are equal.

string1 != string2

True if the strings are not equal.

! expr

True if expr is false.

expr1a expr2

True if both expr1 and expr2 are true.

expr1o expr2

True if either expr1 or expr2 is true.

arg1 OP arg2

OP is one of −eq, −ne, −lt, −le, −gt, or −ge. These arithmetic binary operators return true if arg1 is equal, not-equal, less-than, less-than-or-equal, greater-than, or greater-than-or-equal than arg2, respectively. arg1 and arg2 may be positive integers, negative integers, or the special expression −l string, which evaluates to the length of string.

OPTIONS
When GNU test is invoked with exactly one argument, the following options are recognized:

−−help

Print a usage message on standard output and exit successfully.

−−version

Print version information on standard output then exit successfully.



test(1)