HP-UX Reference (11i v2 07/12) - 1 User Commands N-Z (vol 2)
s
sh-posix(1) sh-posix(1)
string < string2 True, if string1 comes before string2 based on the ASCII value of their charac-
ters.
string
> string2 True, if string1 comes after string2 based on the ASCII value of their characters.
exp1
-eq exp2 True, if exp1 is equal to exp2.
exp1
-ne exp2 True, if exp1 is not equal to exp2.
exp1
-lt exp2 True, if exp1 is less than exp2.
exp1
-gt exp2 True, if exp1 is greater than exp2.
exp1
-le exp2 True, if exp1 is less than or equal to exp2.
exp1
-ge exp2 True, if exp1 is greater than or equal to exp2.
A compound expression can be constructed from these primitives by using any of the following, listed in
decreasing order of precedence.
(exp) True, if exp is true. Used to group expressions.
!exp True, if exp is false.
exp1
&& exp2 True, if exp1 and exp2 are both true.
exp1
|| exp2 True, if either exp1 or exp2 is true.
Input/Output
Before a command is executed, its input and output can be redirected using a special notation interpreted
by the shell. The following can appear anywhere in a simple-command or may precede or follow a com-
mand and are not passed on to the invoked command. Command and parameter substitution occurs before
word or digit is used, except as noted below. File name generation occurs only if the pattern matches a sin-
gle file and blank interpretation is not performed.
<word Use file word as standard input (file descriptor 0).
>word Use file word as standard output (file descriptor 1). If the file does not exist, it is
created. If the file exists, and the noclobber option is on, an error occurs; other-
wise, the file is truncated to zero length.
>|word Same as >, except that it overrides the noclobber option.
>>word Use file word as standard output. If the file exists, output is appended to it (by first
searching for the end-of-file); otherwise, the file is created.
<>word Open file word for reading and writing as standard input.
<<[-]word The shell input is read up to a line that matches word, or to an end-of-file. No param-
eter substitution, command substitution or file name generation is performed on
word. The resulting document, called a here-document, becomes the standard
input. See also the WARNINGS section.
If any character of word is quoted, no interpretation is placed upon the characters of
the document. Otherwise, parameter and command substitution occurs,
\newline is
ignored, and \ must be used to quote the characters \, $, ‘, and the first character of
word.
If
- is appended to <<, all leading tabs are stripped from word and from the docu-
ment.
<&digit The standard input is duplicated from file descriptor digit (see dup(2)).
>&digit The standard output is duplicated to file descriptor digit (see dup(2)).
<&- The standard input is closed.
>&- The standard output is closed.
<&p The input from the coprocess is moved to standard input.
>&p The output to the coprocess is moved to standard output.
If any of the above redirections is preceded by a digit (0 to 9), the file descriptor used is the one specified by
the digit, instead of the default 0 (standard input) or 1 (standard output). For example:
2>&1
means open file descriptor 2 for writing as a duplicate of file descriptor 1. Output directed to file descriptor
2 is written in the same location as output to file descriptor 1.
282 Hewlett-Packard Company − 18 − HP-UX 11i Version 2: December 2007 Update