@node Exit status
@section Exit status
+@macro exitstatus
+An exit status of zero indicates success,
+and a value of @samp{1} indicates failure.
+@end macro
+
Nearly every command invocation yields an integral @dfn{exit status}
that can be used to change how other commands work.
For the vast majority of commands, an exit status of zero indicates
@end table
+@exitstatus
+
@node tac invocation
@section @command{tac}: Concatenate and write files in reverse
@end table
+@exitstatus
+
@node nl invocation
@section @command{nl}: Number lines and write files
@end table
+@exitstatus
+
@node od invocation
@section @command{od}: Write files in octal or other formats
@end table
+@exitstatus
+
@node Formatting file contents
@chapter Formatting file contents
@end table
+@exitstatus
+
@node pr invocation
@section @command{pr}: Paginate or columnate files for printing
@end table
+@exitstatus
+
@node fold invocation
@section @command{fold}: Wrap input lines to fit in specified width
@end table
+@exitstatus
+
@node Output of parts of files
@chapter Output of parts of files
@acronym{POSIX} 1003.1-2001 (@pxref{Standards conformance}) does not allow
this; use @option{-c @var{count}} or @option{-n @var{count}} instead.
+@exitstatus
+
+
@node tail invocation
@section @command{tail}: Output the last part of files
conformance}) does not allow these options; use @option{-c
@var{count}} or @option{-n @var{count}} instead.
+@exitstatus
+
+
@node split invocation
@section @command{split}: Split a file into fixed-size pieces
@end table
+@exitstatus
+
@node csplit invocation
@section @command{csplit}: Split a file into context-determined pieces
@end table
+@exitstatus
+
@node Summarizing files
@chapter Summarizing files
@end table
+@exitstatus
+
@node sum invocation
@section @command{sum}: Print checksum and block counts
@command{sum} is provided for compatibility; the @command{cksum} program (see
next section) is preferable in new applications.
+@exitstatus
+
@node cksum invocation
@section @command{cksum}: Print CRC checksum and byte counts
The only options are @option{--help} and @option{--version}. @xref{Common
options}.
+@exitstatus
+
@node md5sum invocation
@section @command{md5sum}: Print or check message-digests
@end table
+@exitstatus
+
@node Operating on sorted files
@chapter Operating on sorted files
@end table
+@exitstatus
+
@node comm invocation
@section @command{comm}: Compare two sorted files line by line
the way the linker handled archive files, which has since been solved
in different ways.
+@exitstatus
+
+
@node ptx invocation
@section @command{ptx}: Produce permuted indexes
@end table
+@exitstatus
+
@node Charset selection in ptx
@subsection Charset selection
@end table
+@exitstatus
+
@node paste invocation
@section @command{paste}: Merge lines of files
@end table
+@exitstatus
+
@node join invocation
@section @command{join}: Join lines on a common field
the @option{--help} and @option{--version} options are recognized.
@xref{Common options}.
+@exitstatus
+
@node Operating on characters
@chapter Operating on characters
The @option{--complement} (@option{-c}) option replaces @var{set1} with its
complement (all of the characters that are not in @var{set1}).
+@exitstatus
+
@menu
* Character sets:: Specifying sets of characters.
* Translating:: Changing one set of characters to another.
@end table
+@exitstatus
+
@node unexpand invocation
@section @command{unexpand}: Convert spaces to tabs
@end table
+@exitstatus
+
@node Directory listing
@chapter Directory listing
The division of options into the subsections is not absolute, since some
options affect more than one aspect of @command{ls}'s operation.
+@exitstatus
+
Also see @ref{Common options}.
@menu
@end table
+@exitstatus
+
@node Basic operations
@chapter Basic operations
@end table
+@exitstatus
+
@node dd invocation
@section @command{dd}: Convert and copy a file
@end table
+@exitstatus
+
@node install invocation
@section @command{install}: Copy files and set attributes
@end table
+@exitstatus
+
@node mv invocation
@section @command{mv}: Move (rename) files
@end table
+@exitstatus
+
@node rm invocation
@section @command{rm}: Remove files or directories
The Unix @command{rm} program's use of a single @samp{-} for this purpose
predates the development of the getopt standard syntax.
+@exitstatus
+
@node shred invocation
@section @command{shred}: Remove files more securely
shred --verbose /dev/sda5
@end example
+@exitstatus
+
+
@node Special file types
@chapter Special file types
@command{link} simply calls @code{link (@var{filename}, @var{linkname})}
to create the link.
+@exitstatus
+
+
@node ln invocation
@section @command{ln}: Make links between files
ln -s a b .. # creates links ../a and ../b pointing to ./a and ./b
@end smallexample
+@exitstatus
+
@node mkdir invocation
@section @command{mkdir}: Make directories
mkdir [@var{option}]@dots{} @var{name}@dots{}
@end example
-If a @var{name} is an existing file but not a directory, @command{mkdir} prints a
-warning message on stderr and will exit with a status of 1 after
+If a @var{name} is an existing file but not a directory, @command{mkdir} prints
+a warning message on stderr and will exit with a status of 1 after
processing any remaining @var{name}s. The same is done when a @var{name} is an
existing directory and the -p option is not given. If a @var{name} is an
existing directory and the -p option is given, @command{mkdir} will ignore it.
@option{--parents}.
@end table
+@exitstatus
+
@node mkfifo invocation
@section @command{mkfifo}: Make FIFOs (named pipes)
@end table
+@exitstatus
+
@node mknod invocation
@section @command{mknod}: Make block or character special files
@end table
+@exitstatus
+
@node readlink invocation
@section @command{readlink}: Print the referent of a symbolic link
@command{readlink} outputs the absolute name of the given file which contains
no `.', `..' components nor any repeated path separators (`/') or symlinks.
-In any path component is missing or unavailable,
+If any path component is missing or unavailable,
it produces no output and exits with a nonzero exit code.
@end table
The @command{readlink} utility first appeared in OpenBSD 2.1.
+@exitstatus
+
@node rmdir invocation
@section @command{rmdir}: Remove empty directories
@xref{rm invocation}, for how to remove non-empty directories (recursively).
+@exitstatus
+
+
@node unlink invocation
@section @command{unlink}: Remove files via the unlink syscall
@env{POSIXLY_CORRECT} is set, @command{unlink} treats such a command line
arguments not as an option, but as an operand.
+@exitstatus
+
@node Changing file attributes
@chapter Changing file attributes
@end table
+@exitstatus
+
@node chgrp invocation
@section @command{chgrp}: Change group ownership
@end table
+@exitstatus
+
@node chmod invocation
@section @command{chmod}: Change access permissions
@end table
+@exitstatus
+
@node touch invocation
@section @command{touch}: Change file timestamps
@end table
+@exitstatus
+
@node Disk usage
@chapter Disk usage
@end table
+@exitstatus
+
@node du invocation
@section @command{du}: Estimate file space usage
files that are NFS-mounted from BSD systems. This is due to a flaw
in HP-UX; it also affects the HP-UX @command{du} program.
+@exitstatus
+
@node stat invocation
@section @command{stat}: Report file or filesystem status
@end itemize
@end table
+@exitstatus
+
@node sync invocation
@section @command{sync}: Synchronize data on disk with memory
Any arguments are ignored, except for a lone @option{--help} or
@option{--version} (@pxref{Common options}).
+@exitstatus
+
+
@node Printing text
@chapter Printing text
@end table
+@exitstatus
+
@node printf invocation
@section @command{printf}: Format and print data
> sample.sh
@end smallexample
+@exitstatus
+
@node yes invocation
@section @command{yes}: Print a string until interrupted
followed by a newline, forever until it is killed. If no arguments are
given, it prints @samp{y} followed by a newline forever until killed.
+Upon a write error, @command{yes} exits with status @samp{1}.
+
The only options are a lone @option{--help} or @option{--version}.
@xref{Common options}.
@end table
+@exitstatus
+
@node File name manipulation
@chapter File name manipulation
The only options are @option{--help} and @option{--version}. @xref{Common
options}.
+@exitstatus
+
@node dirname invocation
@section @command{dirname}: Strip non-directory suffix from a file name
The only options are @option{--help} and @option{--version}. @xref{Common
options}.
+@exitstatus
+
@node pathchk invocation
@section @command{pathchk}: Check file name portability
The only options are a lone @option{--help} or
@option{--version}. @xref{Common options}.
+@exitstatus
+
@node stty invocation
@section @command{stty}: Print or change terminal characteristics
be available, but it's not feasible to document all the variations: just
try it and see.
+@exitstatus
+
@menu
* Control:: Control settings
* Input:: Input settings
@end table
+@exitstatus
+
@node logname invocation
@section @command{logname}: Print current login name
The only options are @option{--help} and @option{--version}. @xref{Common
options}.
+@exitstatus
+
@node whoami invocation
@section @command{whoami}: Print effective user id
The only options are @option{--help} and @option{--version}. @xref{Common
options}.
+@exitstatus
+
@node groups invocation
@section @command{groups}: Print group names a user is in
The only options are @option{--help} and @option{--version}. @xref{Common
options}.
+@exitstatus
+
@node users invocation
@section @command{users}: Print login names of users currently logged in
The only options are @option{--help} and @option{--version}. @xref{Common
options}.
+@exitstatus
+
@node who invocation
@section @command{who}: Print who is currently logged in
@end table
+@exitstatus
+
@node System context
@chapter System context
directives, which start with @samp{%}, characters in the format string
are printed unchanged. The directives are described below.
+@exitstatus
+
@menu
* Time directives:: %[HIklMprsSTXzZ]
* Date directives:: %[aAbBcdDhjmUwWxyY]
@end table
+@exitstatus
+
+
@node hostname invocation
@section @command{hostname}: Print or set system name
The only options are @option{--help} and @option{--version}. @xref{Common
options}.
+@exitstatus
+
@node hostid invocation
@section @command{hostid}: Print numeric host identifier.
related to the system's Internet address, but that isn't always
the case.
+@exitstatus
+
@node Modified command invocation
@chapter Modified command invocation
Finally, if the executable requires any other files (e.g., data, state,
device files), copy them into place, too.
+@cindex exit status of @command{chroot}
+Exit status:
+
+@display
+1 if there are invalid options, if the chroot syscall fails,
+ or if the subsequent @samp{chdir ("/")} fails
+126 if @var{command} is found but cannot be invoked
+127 if @var{command} cannot be found
+127 if @var{command} cannot be found
+the exit status of @var{command} otherwise
+@end display
+
@node env invocation
@section @command{env}: Run a command in a modified environment
@end table
+@cindex exit status of @command{env}
+Exit status:
+
+@display
+0 if no @var{command} was specified and the environment was output
+1 if no @var{command} was specified and there was a write error while
+ printing the environment
+126 if @var{command} is found but cannot be invoked
+127 if @var{command} cannot be found
+the exit status of @var{command} otherwise
+@end display
+
@node nice invocation
@section @command{nice}: Run a command with modified scheduling priority
@end table
+@cindex exit status of @command{nice}
+Exit status:
+
+@display
+0 if no @var{command} was specified and the current priority was output
+1 if there are invalid options or if no @var{command} was specified and
+ there was a write error
+126 if @var{command} is found but cannot be invoked
+127 if @var{command} cannot be found
+the exit status of @var{command} otherwise
+@end display
+
@node nohup invocation
@section @command{nohup}: Run a command immune to hangups
Exit status:
@display
-126 if @var{command} was found but could not be invoked
-127 if @command{nohup} itself failed or if @var{command} could not be found
+126 if @var{command} is found but cannot be invoked
+127 if @command{nohup} itself fails or if @var{command} cannot be found
the exit status of @var{command} otherwise
@end display
The only options are @option{--help} and @option{--version}. @xref{Common
options}.
+@exitstatus
+
@node Numeric operations
@chapter Numeric operations
18446744073709551615: 3 5 17 257 641 65537 6700417
@end example
+@exitstatus
+
+
@node seq invocation
@section @command{seq}: Print numeric sequences
value for @var{last} to ensure that @var{last} is the final value printed
by seq.
+@exitstatus
+
+
@node File permissions
@chapter File permissions
@include perm.texi