man-pages/man1/test.1.html
2021-03-31 01:06:50 +01:00

201 lines
5.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of TEST</TITLE>
</HEAD><BODY>
<H1>TEST</H1>
Section: User Commands (1)<BR>Updated: September 2019<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
test - check file types and compare values
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>test</B>
<I>EXPRESSION</I>
<BR>
<B>test</B>
<BR>
<B>[</B>
<I>EXPRESSION</I>
<B>]</B>
<BR>
<B>[ ]</B>
<BR>
<B>[</B>
<I>OPTION</I>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<P>
Exit with the status determined by EXPRESSION.
<DL COMPACT>
<DT id="1"><B>--help</B><DD>
display this help and exit
<DT id="2"><B>--version</B><DD>
output version information and exit
</DL>
<P>
An omitted EXPRESSION defaults to false. Otherwise,
EXPRESSION is true or false and sets exit status. It is one of:
<DL COMPACT>
<DT id="3">( EXPRESSION )<DD>
EXPRESSION is true
<DT id="4">! EXPRESSION<DD>
EXPRESSION is false
<DT id="5">EXPRESSION1 <B>-a</B> EXPRESSION2<DD>
both EXPRESSION1 and EXPRESSION2 are true
<DT id="6">EXPRESSION1 <B>-o</B> EXPRESSION2<DD>
either EXPRESSION1 or EXPRESSION2 is true
<DT id="7"><B>-n</B> STRING<DD>
the length of STRING is nonzero
<DT id="8">STRING<DD>
equivalent to <B>-n</B> STRING
<DT id="9"><B>-z</B> STRING<DD>
the length of STRING is zero
<DT id="10">STRING1 = STRING2<DD>
the strings are equal
<DT id="11">STRING1 != STRING2<DD>
the strings are not equal
<DT id="12">INTEGER1 <B>-eq</B> INTEGER2<DD>
INTEGER1 is equal to INTEGER2
<DT id="13">INTEGER1 <B>-ge</B> INTEGER2<DD>
INTEGER1 is greater than or equal to INTEGER2
<DT id="14">INTEGER1 <B>-gt</B> INTEGER2<DD>
INTEGER1 is greater than INTEGER2
<DT id="15">INTEGER1 <B>-le</B> INTEGER2<DD>
INTEGER1 is less than or equal to INTEGER2
<DT id="16">INTEGER1 <B>-lt</B> INTEGER2<DD>
INTEGER1 is less than INTEGER2
<DT id="17">INTEGER1 <B>-ne</B> INTEGER2<DD>
INTEGER1 is not equal to INTEGER2
<DT id="18">FILE1 <B>-ef</B> FILE2<DD>
FILE1 and FILE2 have the same device and inode numbers
<DT id="19">FILE1 <B>-nt</B> FILE2<DD>
FILE1 is newer (modification date) than FILE2
<DT id="20">FILE1 <B>-ot</B> FILE2<DD>
FILE1 is older than FILE2
<DT id="21"><B>-b</B> FILE<DD>
FILE exists and is block special
<DT id="22"><B>-c</B> FILE<DD>
FILE exists and is character special
<DT id="23"><B>-d</B> FILE<DD>
FILE exists and is a directory
<DT id="24"><B>-e</B> FILE<DD>
FILE exists
<DT id="25"><B>-f</B> FILE<DD>
FILE exists and is a regular file
<DT id="26"><B>-g</B> FILE<DD>
FILE exists and is set-group-ID
<DT id="27"><B>-G</B> FILE<DD>
FILE exists and is owned by the effective group ID
<DT id="28"><B>-h</B> FILE<DD>
FILE exists and is a symbolic link (same as <B>-L</B>)
<DT id="29"><B>-k</B> FILE<DD>
FILE exists and has its sticky bit set
<DT id="30"><B>-L</B> FILE<DD>
FILE exists and is a symbolic link (same as <B>-h</B>)
<DT id="31"><B>-O</B> FILE<DD>
FILE exists and is owned by the effective user ID
<DT id="32"><B>-p</B> FILE<DD>
FILE exists and is a named pipe
<DT id="33"><B>-r</B> FILE<DD>
FILE exists and read permission is granted
<DT id="34"><B>-s</B> FILE<DD>
FILE exists and has a size greater than zero
<DT id="35"><B>-S</B> FILE<DD>
FILE exists and is a socket
<DT id="36"><B>-t</B> FD<DD>
file descriptor FD is opened on a terminal
<DT id="37"><B>-u</B> FILE<DD>
FILE exists and its set-user-ID bit is set
<DT id="38"><B>-w</B> FILE<DD>
FILE exists and write permission is granted
<DT id="39"><B>-x</B> FILE<DD>
FILE exists and execute (or search) permission is granted
</DL>
<P>
Except for <B>-h</B> and <B>-L</B>, all FILE-related tests dereference symbolic links.
Beware that parentheses need to be escaped (e.g., by backslashes) for shells.
INTEGER may also be <B>-l</B> STRING, which evaluates to the length of STRING.
<P>
NOTE: Binary <B>-a</B> and <B>-o</B> are inherently ambiguous. Use 'test EXPR1 &amp;&amp; test
EXPR2' or 'test EXPR1 || test EXPR2' instead.
<P>
NOTE: [ honors the <B>--help</B> and <B>--version</B> options, but test does not.
test treats each of those as it treats any other nonempty STRING.
<P>
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.
<A NAME="lbAE">&nbsp;</A>
<H2>AUTHOR</H2>
Written by Kevin Braunsdorf and Matthew Bradburn.
<A NAME="lbAF">&nbsp;</A>
<H2>REPORTING BUGS</H2>
GNU coreutils online help: &lt;<A HREF="https://www.gnu.org/software/coreutils/">https://www.gnu.org/software/coreutils/</A>&gt;
<BR>
Report [ translation bugs to &lt;<A HREF="https://translationproject.org/team/">https://translationproject.org/team/</A>&gt;
<A NAME="lbAG">&nbsp;</A>
<H2>COPYRIGHT</H2>
Copyright &#169; 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;<A HREF="https://gnu.org/licenses/gpl.html">https://gnu.org/licenses/gpl.html</A>&gt;.
<BR>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
Full documentation at: &lt;<A HREF="https://www.gnu.org/software/coreutils/[">https://www.gnu.org/software/coreutils/[</A>&gt;
<BR>
or available locally via: info '(coreutils) test invocation'
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="40"><A HREF="#lbAB">NAME</A><DD>
<DT id="41"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="42"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="43"><A HREF="#lbAE">AUTHOR</A><DD>
<DT id="44"><A HREF="#lbAF">REPORTING BUGS</A><DD>
<DT id="45"><A HREF="#lbAG">COPYRIGHT</A><DD>
<DT id="46"><A HREF="#lbAH">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:28 GMT, March 31, 2021
</BODY>
</HTML>