HP-UX Reference (11i v3 07/02) - 1 User Commands A-M (vol 1)
k
ksh(1) ksh(1)
-d file True if file exists and is a directory.
-f file True if file exists and is an ordinary file.
-g file True if file exists and is has its setgid bit set.
-h file True if file exists and is a a symbolic link.
-k file True if file exists and is has its sticky bit set.
-n string True if length of string is nonzero.
-o option True if option named option is on.
-p file True if file exists and is a fifo special file or a pipe.
-r file True if file exists and is readable by current process.
-s file True if file exists and has size greater than zero.
-t fildes True if file descriptor number fildes is open and associated with a terminal dev-
ice.
-u file True if file exists and is has its setuid bit set.
-w file True if file exists and is writable by current process.
-x file True if file exists and is executable by current process. If file exists and is a
directory, the current process has permission to search in the directory.
-z string True if length of string is zero.
-L file True if file exists and is a symbolic link.
-O file True if file exists and is owned by the effective user ID of this process.
-G file True if file exists and its group matches the effective group ID of this process.
-S file True if file exists and is a socket.
file1 -nt file2 True if file1 exists and is newer than file2.
file1
-ot file2 True if file1 exists and is older than file2.
file1
-ef file2 True if file1 and file2 exist and refer to the same file.
string = pattern True if string matches pattern.
string != pattern True if string does not match pattern.
string1 < string2 True if string1 comes before string2 based on the ASCII value of their charac-
ters.
string1 > 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.
(expression) True, if expression is true. Used to group expressions.
! expression True if expression is false.
expression1 && expression2 True, if expression1 and expression2 are both true.
expression1 || expression2 True, if either expression1 or expression2 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 can precede or follow a command
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 single 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. Note that the noclobber test is only
applied to regular files, not to named pipes or other file types.
>|word Sames 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. If the file does not exist it
is created.
496 Hewlett-Packard Company − 8 − HP-UX 11i Version 3: February 2007