X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=doc%2Fcoreutils.texi;h=e29af8bec0ddcf0c0540b431f560efe2674af4e8;hb=d57ebc45ba4c59cc6f8bb0e9a435ecbddc84b982;hp=adcd848e344122a4201c866bd23f76929640485d;hpb=8d0b79afa54a5a0a7afcef415eb62fa0c8a33451;p=platform%2Fupstream%2Fcoreutils.git diff --git a/doc/coreutils.texi b/doc/coreutils.texi index adcd848..e29af8b 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -1,7 +1,7 @@ \input texinfo @c %**start of header @setfilename coreutils.info -@settitle @sc{gnu} Coreutils +@settitle GNU Coreutils @c %**end of header @@ -23,7 +23,7 @@ @dircategory Basics @direntry * Coreutils: (coreutils). Core GNU (file, text, shell) utilities. -* Common options: (coreutils)Common options. Common options. +* Common options: (coreutils)Common options. * File permissions: (coreutils)File permissions. Access modes. * Date input formats: (coreutils)Date input formats. @end direntry @@ -40,8 +40,8 @@ * cat: (coreutils)cat invocation. Concatenate and write files. * chcon: (coreutils)chcon invocation. Change SELinux CTX of files. * chgrp: (coreutils)chgrp invocation. Change file groups. -* chmod: (coreutils)chmod invocation. Change file permissions. -* chown: (coreutils)chown invocation. Change file owners/groups. +* chmod: (coreutils)chmod invocation. Change access permissions. +* chown: (coreutils)chown invocation. Change file owners and groups. * chroot: (coreutils)chroot invocation. Specify the root directory. * cksum: (coreutils)cksum invocation. Print POSIX CRC checksum. * comm: (coreutils)comm invocation. Compare sorted files by line. @@ -94,6 +94,7 @@ * ptx: (coreutils)ptx invocation. Produce permuted indexes. * pwd: (coreutils)pwd invocation. Print working directory. * readlink: (coreutils)readlink invocation. Print referent of a symlink. +* realpath: (coreutils)readpath invocation. Print resolved file names. * rm: (coreutils)rm invocation. Remove files. * rmdir: (coreutils)rmdir invocation. Remove empty directories. * runcon: (coreutils)runcon invocation. Run in specified SELinux CTX. @@ -108,7 +109,6 @@ * stat: (coreutils)stat invocation. Report file(system) status. * stdbuf: (coreutils)stdbuf invocation. Modify stdio buffering. * stty: (coreutils)stty invocation. Print/change terminal settings. -* su: (coreutils)su invocation. Modify user and group ID. * sum: (coreutils)sum invocation. Print traditional checksum. * sync: (coreutils)sync invocation. Synchronize memory and disk. * tac: (coreutils)tac invocation. Reverse files. @@ -136,10 +136,10 @@ @end direntry @copying -This manual documents version @value{VERSION} of the @sc{gnu} core +This manual documents version @value{VERSION} of the GNU core utilities, including the standard programs for text and file manipulation. -Copyright @copyright{} 1994-1996, 2000-2011 Free Software Foundation, Inc. +Copyright @copyright{} 1994-2013 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document @@ -152,7 +152,7 @@ Free Documentation License''. @end copying @titlepage -@title @sc{gnu} @code{Coreutils} +@title GNU @code{Coreutils} @subtitle Core GNU utilities @subtitle for version @value{VERSION}, @value{UPDATED} @author David MacKenzie et al. @@ -194,12 +194,12 @@ Free Documentation License''. * Printing text:: echo printf yes * Conditions:: false true test expr * Redirection:: tee -* File name manipulation:: dirname basename pathchk mktemp +* File name manipulation:: dirname basename pathchk mktemp realpath * Working context:: pwd stty printenv tty * User information:: id logname whoami groups users who * System context:: date arch nproc uname hostname hostid uptime * SELinux context:: chcon runcon -* Modified command invocation:: chroot env nice nohup stdbuf su timeout +* Modified command invocation:: chroot env nice nohup stdbuf timeout * Process control:: kill * Delaying:: sleep * Numeric operations:: factor seq @@ -272,7 +272,7 @@ Operating on sorted files * Charset selection in ptx:: Underlying character set considerations * Input processing in ptx:: Input fields, contexts, and keyword selection * Output formatting in ptx:: Types of output format, and sizing the fields -* Compatibility in ptx:: The @acronym{GNU} extensions to @command{ptx} +* Compatibility in ptx:: The GNU extensions to @command{ptx} Operating on fields @@ -381,6 +381,7 @@ File name manipulation * dirname invocation:: Strip last file name component * pathchk invocation:: Check file name validity and portability * mktemp invocation:: Create temporary file or directory +* realpath invocation:: Print resolved file names Working context @@ -441,7 +442,6 @@ Modified command invocation * nice invocation:: Run a command with modified niceness * nohup invocation:: Run a command immune to hangups * stdbuf invocation:: Run a command with modified I/O buffering -* su invocation:: Run a command with substitute user and group ID * timeout invocation:: Run a command with a time limit Process control @@ -469,13 +469,14 @@ Date input formats * General date syntax:: Common rules * Calendar date items:: 19 Dec 1994 * Time of day items:: 9:20pm -* Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt} +* Time zone items:: EST, PDT, UTC, @dots{} +* Combined date and time of day items:: 1972-09-24T20:02:00,000000-0500 * Day of week items:: Monday and others * Relative items in date strings:: next tuesday, 2 years ago * Pure numbers in date strings:: 19931219, 1440 * Seconds since the Epoch:: @@1078100502 * Specifying time zone rules:: TZ="America/New_York", TZ="UTC0" -* Authors of parse_datetime:: Bellovin, Eggert, Salz, Berets, et al +* Authors of parse_datetime:: Bellovin, Eggert, Salz, Berets, et al. Opening the software toolbox @@ -500,12 +501,12 @@ Copying This Manual This manual is a work in progress: many sections make no attempt to explain basic concepts in a way suitable for novices. Thus, if you are interested, -please get involved in improving this manual. The entire @sc{gnu} community +please get involved in improving this manual. The entire GNU community will benefit. -@cindex @acronym{POSIX} -The @sc{gnu} utilities documented here are mostly compatible with the -@acronym{POSIX} standard. +@cindex POSIX +The GNU utilities documented here are mostly compatible with the +POSIX standard. @cindex bugs, reporting Please report bugs to @email{bug-coreutils@@gnu.org}. Remember to include the version number, machine architecture, input files, and @@ -583,15 +584,15 @@ symbolic link to a directory. @xref{Target directory}. @opindex -0 @itemx --null @opindex --null -@cindex output @sc{nul}-byte-terminated lines -Output a zero byte (@acronym{ASCII} @sc{nul}) at the end of each line, -rather than a newline. This option enables other programs to parse the +@cindex output NUL-byte-terminated lines +Output a zero byte (ASCII NUL) at the end of each line, +rather than a newline. This option enables other programs to parse the output of @command{\cmd\} even when that output would contain data with embedded newlines. @end macro @macro optSi -@itemx --si +@item --si @opindex --si @cindex SI output Append an SI-style abbreviation to each size, such as @samp{M} for @@ -615,7 +616,7 @@ Use the @option{--si} option if you prefer powers of 1000. @end macro @macro optStripTrailingSlashes -@itemx @w{@kbd{--strip-trailing-slashes}} +@item @w{@kbd{--strip-trailing-slashes}} @opindex --strip-trailing-slashes @cindex stripping trailing slashes Remove any trailing slashes from each @var{source} argument. @@ -667,7 +668,7 @@ and so on for @samp{T}, @samp{P}, @samp{E}, @samp{Z}, and @samp{Y}. Certain options are available in all of these programs. Rather than writing identical descriptions for each of the programs, they are -described here. (In fact, every @sc{gnu} program accepts (or should accept) +described here. (In fact, every GNU program accepts (or should accept) these options.) @vindex POSIXLY_CORRECT @@ -739,7 +740,7 @@ name. * Traversing symlinks:: -H, -L, or -P, in some programs. * Treating / specially:: --preserve-root and --no-preserve-root. * Special built-in utilities:: @command{break}, @command{:}, @dots{} -* Standards conformance:: Conformance to the @acronym{POSIX} standard. +* Standards conformance:: Conformance to the POSIX standard. @end menu @@ -755,7 +756,7 @@ 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 success. Failure is indicated by a nonzero value---typically -@samp{1}, though it may differ on unusual platforms as @acronym{POSIX} +@samp{1}, though it may differ on unusual platforms as POSIX requires only that it be nonzero. However, some of the programs documented here do produce @@ -764,7 +765,7 @@ meanings with the values @samp{0} and @samp{1}. Here are some of the exceptions: @command{chroot}, @command{env}, @command{expr}, @command{nice}, @command{nohup}, @command{printenv}, @command{sort}, @command{stdbuf}, -@command{su}, @command{test}, @command{timeout}, @command{tty}. +@command{test}, @command{timeout}, @command{tty}. @node Backup options @@ -772,7 +773,7 @@ Here are some of the exceptions: @cindex backup options -Some @sc{gnu} programs (at least @command{cp}, @command{install}, +Some GNU programs (at least @command{cp}, @command{install}, @command{ln}, and @command{mv}) optionally make backups of files before writing new versions. These options control the details of these backups. The options are also @@ -846,7 +847,7 @@ set, the default is @samp{~}, just as in Emacs. @cindex block size -Some @sc{gnu} programs (at least @command{df}, @command{du}, and +Some GNU programs (at least @command{df}, @command{du}, and @command{ls}) display sizes in ``blocks''. You can adjust the block size and method of display to make sizes easier to read. The block size used for display is independent of any file system block size. @@ -901,10 +902,10 @@ A block size specification can be a positive integer specifying the number of bytes per block, or it can be @code{human-readable} or @code{si} to select a human-readable format. Integers may be followed by suffixes that are upward compatible with the -@uref{http://www.bipm.fr/enus/3_SI/si-prefixes.html, SI prefixes} +@uref{http://www.bipm.org/en/si/si_brochure/chapter3/prefixes.html, SI prefixes} for decimal multiples and with the -@uref{http://physics.nist.gov/cuu/Units/binary.html, IEC 60027-2 -prefixes for binary multiples}. +@uref{http://physics.nist.gov/cuu/Units/binary.html, ISO/IEC 80000-13 +(formerly IEC 60027-2) prefixes} for binary multiples. With human-readable formats, output sizes are followed by a size letter such as @samp{M} for megabytes. @code{BLOCK_SIZE=human-readable} uses @@ -946,8 +947,8 @@ kilobyte: @math{10^3 = 1000}. @itemx KiB @cindex kibibyte, definition of kibibyte: @math{2^{10} = 1024}. @samp{K} is special: the SI prefix is -@samp{k} and the IEC 60027-2 prefix is @samp{Ki}, but tradition and -@acronym{POSIX} use @samp{k} to mean @samp{KiB}. +@samp{k} and the ISO/IEC 80000-13 prefix is @samp{Ki}, but tradition and +POSIX use @samp{k} to mean @samp{KiB}. @item MB @cindex megabyte, definition of megabyte: @math{10^6 = 1,000,000}. @@ -989,14 +990,12 @@ zettabyte: @math{10^{21} = 1,000,000,000,000,000,000,000} @item Z @itemx ZiB @math{2^{70} = 1,180,591,620,717,411,303,424}. -(@samp{Zi} is a @acronym{GNU} extension to IEC 60027-2.) @item YB @cindex yottabyte, definition of yottabyte: @math{10^{24} = 1,000,000,000,000,000,000,000,000}. @item Y @itemx YiB @math{2^{80} = 1,208,925,819,614,629,174,706,176}. -(@samp{Yi} is a @acronym{GNU} extension to IEC 60027-2.) @end table @opindex -k @@ -1048,8 +1047,8 @@ floating point numbers such as @code{-0x.ep-3}, which stands for A @var{signal} may be a signal name like @samp{HUP}, or a signal number like @samp{1}, or an exit status of a process terminated by the signal. A signal name can be given in canonical form or prefixed by -@samp{SIG}. The case of the letters is ignored. The following signal names -and numbers are supported on all @acronym{POSIX} compliant systems: +@samp{SIG}@. The case of the letters is ignored. The following signal names +and numbers are supported on all POSIX compliant systems: @table @samp @item HUP @@ -1070,7 +1069,7 @@ and numbers are supported on all @acronym{POSIX} compliant systems: @noindent Other supported signal names have system-dependent corresponding -numbers. All systems conforming to @acronym{POSIX} 1003.1-2001 also +numbers. All systems conforming to POSIX 1003.1-2001 also support the following signals: @table @samp @@ -1105,7 +1104,7 @@ User-defined signal 2. @end table @noindent -@acronym{POSIX} 1003.1-2001 systems that support the @acronym{XSI} extension +POSIX 1003.1-2001 systems that support the XSI extension also support the following signals: @table @samp @@ -1126,7 +1125,7 @@ File size limit exceeded. @end table @noindent -@acronym{POSIX} 1003.1-2001 systems that support the @acronym{XRT} extension +POSIX 1003.1-2001 systems that support the XRT extension also support at least eight real-time signals called @samp{RTMIN}, @samp{RTMIN+1}, @dots{}, @samp{RTMAX-1}, @samp{RTMAX}. @@ -1143,10 +1142,10 @@ Since the @var{owner} and @var{group} arguments to @command{chown} and apparent ambiguity. What if a user or group @emph{name} is a string of digits? @footnote{Using a number as a user name is common in some environments.} -Should the command interpret it as a user name or as an ID? -@acronym{POSIX} requires that @command{chown} and @command{chgrp} +Should the command interpret it as a user name or as an ID@? +POSIX requires that @command{chown} and @command{chgrp} first attempt to resolve the specified string as a name, and -only once that fails, then try to interpret it as an ID. +only once that fails, then try to interpret it as an ID@. This is troublesome when you want to specify a numeric ID, say 42, and it must work even in a pathological situation where @samp{42} is a user name that maps to some other user ID, say 1000. @@ -1272,7 +1271,7 @@ ls | xargs mv -t ../d -- @end smallexample However, this doesn't move files whose names begin with @samp{.}. -If you use the @sc{gnu} @command{find} program, you can move those +If you use the GNU @command{find} program, you can move those files too, with this command: @example @@ -1284,7 +1283,7 @@ But both of the above approaches fail if there are no files in the current directory, or if any file has a name containing a blank or some other special characters. The following example removes those limitations and requires both -@sc{gnu} @command{find} and @sc{gnu} @command{xargs}: +GNU @command{find} and GNU @command{xargs}: @example find . -mindepth 1 -maxdepth 1 -print0 \ @@ -1304,7 +1303,7 @@ options cannot be combined. @cindex trailing slashes -Some @sc{gnu} programs (at least @command{cp} and @command{mv}) allow you to +Some GNU programs (at least @command{cp} and @command{mv}) allow you to remove any trailing slashes from each @var{source} argument before operating on it. The @w{@kbd{--strip-trailing-slashes}} option enables this behavior. @@ -1318,7 +1317,7 @@ option, @command{mv}, for example, (via the system's rename function) must interpret a trailing slash as a request to dereference the symbolic link and so must rename the indirectly referenced @emph{directory} and not the symbolic link. Although it may seem surprising that such behavior -be the default, it is required by @acronym{POSIX} and is consistent with +be the default, it is required by POSIX and is consistent with other parts of that standard. @node Traversing symlinks @@ -1327,7 +1326,7 @@ other parts of that standard. @cindex symbolic link to directory, controlling traversal of The following options modify how @command{chown} and @command{chgrp} -@c FIXME: note that `du' has these options, too, but they have slightly +@c FIXME: note that 'du' has these options, too, but they have slightly @c different meaning. traverse a hierarchy when the @option{--recursive} (@option{-R}) option is also specified. @@ -1382,11 +1381,11 @@ For example, if a user with appropriate privileges mistakenly runs @samp{rm -rf / tmp/junk}, that may remove all files on the entire system. Since there are so few legitimate uses for such a command, -@sc{gnu} @command{rm} normally declines to operate on any directory +GNU @command{rm} normally declines to operate on any directory that resolves to @file{/}. If you really want to try to remove all the files on your system, you can use the @option{--no-preserve-root} option, but the default behavior, specified by the -@option{--preserve-option}, is safer for most purposes. +@option{--preserve-root} option, is safer for most purposes. The commands @command{chgrp}, @command{chmod} and @command{chown} can also operate destructively on entire hierarchies, so they too @@ -1394,7 +1393,7 @@ support these options. Although, unlike @command{rm}, they don't actually unlink files, these commands are arguably more dangerous when operating recursively on @file{/}, since they often work much more quickly, and hence damage more files before an alert user can -interrupt them. Tradition and @acronym{POSIX} require these commands +interrupt them. Tradition and POSIX require these commands to operate recursively on @file{/}, so they default to @option{--no-preserve-root}, but using the @option{--preserve-root} option makes them safer for most purposes. For convenience you can @@ -1416,7 +1415,7 @@ well-defined behavior: it may generate an error message instead of exiting. Here is a list of the special built-in utilities that are standardized -by @acronym{POSIX} 1003.1-2004. +by POSIX 1003.1-2004. @quotation @t{.@: : break continue eval exec exit export readonly @@ -1436,31 +1435,31 @@ generates an error message instead of suspending. @section Standards conformance @vindex POSIXLY_CORRECT -In a few cases, the @sc{gnu} utilities' default behavior is -incompatible with the @acronym{POSIX} standard. To suppress these +In a few cases, the GNU utilities' default behavior is +incompatible with the POSIX standard. To suppress these incompatibilities, define the @env{POSIXLY_CORRECT} environment -variable. Unless you are checking for @acronym{POSIX} conformance, you +variable. Unless you are checking for POSIX conformance, you probably do not need to define @env{POSIXLY_CORRECT}. -Newer versions of @acronym{POSIX} are occasionally incompatible with older -versions. For example, older versions of @acronym{POSIX} required the +Newer versions of POSIX are occasionally incompatible with older +versions. For example, older versions of POSIX required the command @samp{sort +1} to sort based on the second and succeeding -fields in each input line, but starting with @acronym{POSIX} 1003.1-2001 +fields in each input line, but starting with POSIX 1003.1-2001 the same command is required to sort the file named @file{+1}, and you must instead use the command @samp{sort -k 2} to get the field-based sort. @vindex _POSIX2_VERSION -The @sc{gnu} utilities normally conform to the version of @acronym{POSIX} +The GNU utilities normally conform to the version of POSIX that is standard for your system. To cause them to conform to a -different version of @acronym{POSIX}, define the @env{_POSIX2_VERSION} +different version of POSIX, define the @env{_POSIX2_VERSION} environment variable to a value of the form @var{yyyymm} specifying the year and month the standard was adopted. Three values are currently supported for @env{_POSIX2_VERSION}: @samp{199209} stands for -@acronym{POSIX} 1003.2-1992, @samp{200112} stands for @acronym{POSIX} -1003.1-2001, and @samp{200809} stands for @acronym{POSIX} 1003.1-2008. +POSIX 1003.2-1992, @samp{200112} stands for POSIX +1003.1-2001, and @samp{200809} stands for POSIX 1003.1-2008. For example, if you have a newer system but are running software -that assumes an older version of @acronym{POSIX} and uses @samp{sort +1} +that assumes an older version of POSIX and uses @samp{sort +1} or @samp{tail +10}, you can work around any compatibility problems by setting @samp{_POSIX2_VERSION=199209} in your environment. @@ -1548,7 +1547,7 @@ Display TAB characters as @samp{^I}. @item -u @opindex -u -Ignored; for @acronym{POSIX} compatibility. +Ignored; for POSIX compatibility. @item -v @itemx --show-nonprinting @@ -1614,10 +1613,7 @@ precedes in the file. @itemx --regex @opindex -r @opindex --regex -Treat the separator string as a regular expression. Users of @command{tac} -on MS-DOS/MS-Windows should note that, since @command{tac} reads files in -binary mode, each line of a text file might end with a CR/LF pair -instead of the Unix-style LF. +Treat the separator string as a regular expression. @item -s @var{separator} @itemx --separator=@var{separator} @@ -1627,8 +1623,18 @@ Use @var{separator} as the record separator, instead of newline. @end table +On systems like MS-DOS that distinguish between text and binary files, +@command{tac} reads and writes in binary mode. + @exitstatus +Example: + +@example +# Reverse a file character by character. +tac -r -s 'x\|[^x]' +@end example + @node nl invocation @section @command{nl}: Number lines and write files @@ -1881,12 +1887,12 @@ Output at most @var{bytes} bytes of the input. Prefixes and suffixes on @opindex --strings @cindex string constants, outputting Instead of the normal output, output only @dfn{string constants}: at -least @var{bytes} consecutive @acronym{ASCII} graphic characters, -followed by a zero byte (@acronym{ASCII} @sc{nul}). -Prefixes and suffixes on @code{bytes} are interpreted as for the +least @var{bytes} consecutive ASCII graphic characters, +followed by a zero byte (ASCII NUL). +Prefixes and suffixes on @var{bytes} are interpreted as for the @option{-j} option. -If @var{n} is omitted with @option{--strings}, the default is 3. +If @var{bytes} is omitted with @option{--strings}, the default is 3. @item -t @var{type} @itemx --format=@var{type} @@ -1900,14 +1906,14 @@ of each output line using each of the data types that you specified, in the order that you specified. Adding a trailing ``z'' to any type specification appends a display -of the @acronym{ASCII} character representation of the printable characters +of the ASCII character representation of the printable characters to the output line generated by the type specification. @table @samp @item a named character, ignoring high-order bit @item c -@acronym{ASCII} character or backslash escape, +ASCII character or backslash escape, @item d signed decimal @item f @@ -1980,7 +1986,7 @@ omitted, the default is 32. @end table The next several options are shorthands for format specifications. -@sc{gnu} @command{od} accepts any combination of shorthands and format +GNU @command{od} accepts any combination of shorthands and format specification options. These options accumulate. @table @samp @@ -1995,7 +2001,7 @@ Output as octal bytes. Equivalent to @samp{-t o1}. @item -c @opindex -c -Output as @acronym{ASCII} characters or backslash escapes. Equivalent to +Output as ASCII characters or backslash escapes. Equivalent to @samp{-t c}. @item -d @@ -2055,7 +2061,7 @@ address. @command{base64} transforms data read from a file, or standard input, into (or from) base64 encoded form. The base64 encoded form uses -printable @acronym{ASCII} characters to represent binary data. +printable ASCII characters to represent binary data. Synopses: @smallexample @@ -2203,9 +2209,15 @@ between sentences to two spaces. @opindex -@var{width} @opindex -w @opindex --width -Fill output lines up to @var{width} characters (default 75). @command{fmt} -initially tries to make lines about 7% shorter than this, to give it -room to balance line lengths. +Fill output lines up to @var{width} characters (default 75 or @var{goal} +plus 10, if @var{goal} is provided). + +@item -g @var{goal} +@itemx --goal=@var{goal} +@opindex -g +@opindex --goal +@command{fmt} initially tries to make lines @var{goal} characters wide. +By default, this is 7% shorter than @var{width}. @item -p @var{prefix} @itemx --prefix=@var{prefix} @@ -2263,44 +2275,14 @@ For single column output no line truncation occurs by default. Use @option{-W} option to truncate lines in that case. -The following changes were made in version 1.22i and apply to later -versions of @command{pr}: -@c FIXME: this whole section here sounds very awkward to me. I -@c made a few small changes, but really it all needs to be redone. - Brian -@c OK, I fixed another sentence or two, but some of it I just don't understand. -@ - Brian -@itemize @bullet - -@item -Some small @var{letter options} (@option{-s}, @option{-w}) have been -redefined for better @acronym{POSIX} compliance. The output of some further -cases has been adapted to other Unix systems. These changes are not -compatible with earlier versions of the program. - -@item -Some @var{new capital letter} options (@option{-J}, @option{-S}, @option{-W}) -have been introduced to turn off unexpected interferences of small letter -options. The @option{-N} option and the second argument @var{last_page} -of @samp{+FIRST_PAGE} offer more flexibility. The detailed handling of -form feeds set in the input files requires the @option{-T} option. - -@item -Capital letter options override small letter ones. - -@item -Some of the option-arguments (compare @option{-s}, @option{-e}, -@option{-i}, @option{-n}) cannot be specified as separate arguments from the -preceding option letter (already stated in the @acronym{POSIX} specification). -@end itemize - The program accepts the following options. Also see @ref{Common options}. @table @samp @item +@var{first_page}[:@var{last_page}] @itemx --pages=@var{first_page}[:@var{last_page}] -@c The two following @opindex lines evoke warnings because they contain `:' -@c The `info' spec does not permit that. If we use those lines, we end +@c The two following @opindex lines evoke warnings because they contain ':' +@c The 'info' spec does not permit that. If we use those lines, we end @c up with truncated index entries that don't work. @c @opindex +@var{first_page}[:@var{last_page}] @c @opindex --pages=@var{first_page}[:@var{last_page}] @@ -2360,7 +2342,7 @@ Double space the output. @cindex time formats @cindex formatting times Format header dates using @var{format}, using the same conventions as -for the command @samp{date +@var{format}}; @xref{date invocation}. +for the command @samp{date +@var{format}}. @xref{date invocation}. Except for directives, which start with @samp{%}, characters in @var{format} are printed unchanged. You can use this option to specify an arbitrary string in place of the header date, @@ -2371,7 +2353,7 @@ e.g., @option{--date-format="Monday morning"}. The default date format is @samp{%Y-%m-%d %H:%M} (for example, @samp{2001-12-04 23:59}); but if the @env{POSIXLY_CORRECT} environment variable is set -and the @env{LC_TIME} locale category specifies the @acronym{POSIX} +and the @env{LC_TIME} locale category specifies the POSIX locale, the default is @samp{%b %e %H:%M %Y} (for example, @samp{Dec@ @ 4 23:59 2001}. @@ -2428,7 +2410,7 @@ Merge lines of full length. Used together with the column options no column alignment used; may be used with @option{--sep-string[=@var{string}]}. @option{-J} has been introduced (together with @option{-W} and @option{--sep-string}) -to disentangle the old (@acronym{POSIX}-compliant) options @option{-w} and +to disentangle the old (POSIX-compliant) options @option{-w} and @option{-s} along with the three column options. @@ -2474,11 +2456,11 @@ separator is the TAB character. In a strict sense a TAB is always printed with single column output only. The TAB width varies with the TAB position, e.g., with the left @var{margin} specified by @option{-o} option. With multicolumn output priority is given to -@samp{equal width of output columns} (a @acronym{POSIX} specification). +@samp{equal width of output columns} (a POSIX specification). The TAB width is fixed to the value of the first column and does not change with different values of left @var{margin}. That means a fixed number of spaces is always printed in the place of the -@var{number-separator} TAB. The tabification depends upon the output +@var{number-separator} TAB@. The tabification depends upon the output position. @item -N @var{line_number} @@ -2515,10 +2497,10 @@ Separate columns by a single character @var{char}. The default for character} with @option{-w}. Without @option{-s} the default separator @samp{space} is set. @option{-s[char]} turns off line truncation of all three column options (@option{-COLUMN}|@option{-a -COLUMN}|@option{-m}) unless -@option{-w} is set. This is a @acronym{POSIX}-compliant formulation. +@option{-w} is set. This is a POSIX-compliant formulation. -@item -S@var{string} +@item -S[@var{string}] @itemx --sep-string[=@var{string}] @opindex -S @opindex --sep-string @@ -2528,8 +2510,8 @@ does not affect line truncation or column alignment. Without @option{-S}, and with @option{-J}, @command{pr} uses the default output separator, TAB@. Without @option{-S} or @option{-J}, @command{pr} uses a @samp{space} -(same as @option{-S"@w{ }"}). @option{--sep-string} with no -@samp{=@var{string}} is equivalent to @option{--sep-string=""}. +(same as @option{-S"@w{ }"}). +If no @samp{@var{string}} argument is specified, @samp{""} is assumed. @item -t @itemx --omit-header @@ -2565,7 +2547,7 @@ output only (default for @var{page_width} is 72). @option{-s[CHAR]} turns off the default page width and any line truncation and column alignment. Lines of full length are merged, regardless of the column options set. No @var{page_width} setting is possible with single column output. -A @acronym{POSIX}-compliant formulation. +A POSIX-compliant formulation. @item -W @var{page_width} @itemx --page_width=@var{page_width} @@ -2579,7 +2561,7 @@ alignment is always used. The separator options @option{-S} or @option{-s} don't affect the @option{-W} option. Default is 72 characters. Without @option{-W @var{page_width}} and without any of the column options NO line truncation is used (defined to keep downward compatibility and to meet -most frequent tasks). That's equivalent to @option{-W 72 -J}. The header +most frequent tasks). That's equivalent to @option{-W 72 -J}@. The header line is never truncated. @end table @@ -2698,7 +2680,7 @@ However, if @var{k} starts with a @samp{-}, print all but the last @var{k} bytes of each file. @multiplierSuffixes{k} -@itemx -n @var{k} +@item -n @var{k} @itemx --lines=@var{k} @opindex -n @opindex --lines @@ -2762,13 +2744,13 @@ one-line header consisting of: before the output for each @var{file}. @cindex BSD @command{tail} -@sc{gnu} @command{tail} can output any amount of data (some other versions of +GNU @command{tail} can output any amount of data (some other versions of @command{tail} cannot). It also has no @option{-r} option (print in reverse), since reversing a file is really a different job from printing the end of a file; BSD @command{tail} (which is the one with @option{-r}) can only reverse files that are at most as large as its buffer, which is typically 32 KiB@. A more reliable and versatile way to reverse files is -the @sc{gnu} @command{tac} command. +the GNU @command{tac} command. The program accepts the following options. Also see @ref{Common options}. @@ -2830,13 +2812,25 @@ no @var{file} operand is specified and standard input is a FIFO or a pipe. Likewise, the @option{-f} option has no effect for any operand specified as @samp{-}, when standard input is a FIFO or a pipe. +With kernel inotify support, output is triggered by file changes +and is generally very prompt. +Otherwise, @command{tail} sleeps for one second between checks--- +use @option{--sleep-interval=@var{n}} to change that default---which can +make the output appear slightly less responsive or bursty. +When using tail without inotify support, you can make it more responsive +by using a sub-second sleep interval, e.g., via an alias like this: + +@example +alias tail='tail -s.1' +@end example + @item -F @opindex -F This option is the same as @option{--follow=name --retry}. That is, tail will attempt to reopen a file when it is removed. Should this fail, tail will keep trying until it becomes accessible again. -@itemx --retry +@item --retry @opindex --retry This option is useful mainly when following by name (i.e., with @option{--follow=name}). @@ -2844,7 +2838,7 @@ Without this option, when tail encounters a file that doesn't exist or is otherwise inaccessible, it reports that fact and never checks it again. -@itemx --sleep-interval=@var{number} +@item --sleep-interval=@var{number} @opindex --sleep-interval Change the number of seconds to wait between iterations (the default is 1.0). During one iteration, every specified file is checked to see if it has @@ -2852,9 +2846,12 @@ changed size. Historical implementations of @command{tail} have required that @var{number} be an integer. However, GNU @command{tail} accepts an arbitrary floating point number. @xref{Floating point}. -When @command{tail} uses inotify, this polling-related option is ignored. +When @command{tail} uses inotify, this polling-related option +is usually ignored. However, if you also specify @option{--pid=@var{p}}, +@command{tail} checks whether process @var{p} is alive at least +every @var{number} seconds. -@itemx --pid=@var{pid} +@item --pid=@var{pid} @opindex --pid When following by name or by descriptor, you may specify the process ID, @var{pid}, of the sole writer of all @var{file} arguments. Then, shortly @@ -2877,7 +2874,7 @@ terminate until long after the real writer has terminated. Note that @option{--pid} cannot be supported on some systems; @command{tail} will print a warning if this is the case. -@itemx --max-unchanged-stats=@var{n} +@item --max-unchanged-stats=@var{n} @opindex --max-unchanged-stats When tailing a file by name, if there have been @var{n} (default n=@value{DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS}) consecutive @@ -2890,7 +2887,7 @@ and when it prints the lines that have accumulated in the new log file. This option is meaningful only when polling (i.e., without inotify) and when following by name. -@itemx -n @var{k} +@item -n @var{k} @itemx --lines=@var{k} @opindex -n @opindex --lines @@ -2942,7 +2939,7 @@ can use a test like @samp{if tail -c +1 /dev/null 2>&1; then @dots{}} to decide which syntax to use. Even if your script assumes the standard behavior, you should still -beware usages whose behaviors differ depending on the @acronym{POSIX} +beware usages whose behaviors differ depending on the POSIX version. For example, avoid @samp{tail - main.c}, since it might be interpreted as either @samp{tail main.c} or as @samp{tail -- - main.c}; avoid @samp{tail -c 4}, since it might mean either @samp{tail @@ -2975,8 +2972,15 @@ The output files' names consist of @var{prefix} (@samp{x} by default) followed by a group of characters (@samp{aa}, @samp{ab}, @dots{} by default), such that concatenating the output files in traditional sorted order by file name produces the original input file (except -@option{-r}). If the output file names are exhausted, @command{split} -reports an error without deleting the output files that it did create. +@option{-nr/@var{n}}). By default split will initially create files +with two generated suffix characters, and will increase this width by two +when the next most significant position reaches the last character. +(@samp{yz}, @samp{zaaa}, @samp{zaab}, @dots{}). In this way an arbitrary +number of output files are supported, which sort as described above, +even in the presence of an @option{--additional-suffix} option. +If the @option{-a} option is specified and the output file names are +exhausted, @command{split} reports an error without deleting the +output files that it did create. The program accepts the following options. Also see @ref{Common options}. @@ -2989,8 +2993,8 @@ The program accepts the following options. Also see @ref{Common options}. Put @var{lines} lines of @var{input} into each output file. For compatibility @command{split} also supports an obsolete -option syntax @option{-@var{lines}}. New scripts should use @option{-l -@var{lines}} instead. +option syntax @option{-@var{lines}}. New scripts should use +@option{-l @var{lines}} instead. @item -b @var{size} @itemx --bytes=@var{size} @@ -3008,6 +3012,25 @@ possible without exceeding @var{size} bytes. Individual lines longer than @var{size} bytes are broken into multiple files. @var{size} has the same format as for the @option{--bytes} option. +@item --filter=@var{command} +@opindex --filter +With this option, rather than simply writing to each output file, +write through a pipe to the specified shell @var{command} for each output file. +@var{command} should use the $FILE environment variable, which is set +to a different output file name for each invocation of the command. +For example, imagine that you have a 1TiB compressed file +that, if uncompressed, would be too large to reside on disk, +yet you must split it into individually-compressed pieces +of a more manageable size. +To do that, you might run this command: + +@example +xz -dc BIG.xz | split -b200G --filter='xz > $FILE.xz' - big- +@end example + +Assuming a 10:1 compression ratio, that would create about fifty 20GiB files +with names @file{big-aa.xz}, @file{big-ab.xz}, @file{big-ac.xz}, etc. + @item -n @var{chunks} @itemx --number=@var{chunks} @opindex -n @@ -3047,13 +3070,26 @@ and so can be a pipe for example. @itemx --suffix-length=@var{length} @opindex -a @opindex --suffix-length -Use suffixes of length @var{length}. The default @var{length} is 2. +Use suffixes of length @var{length}. If a @var{length} of 0 is specified, +this is the same as if (any previous) @option{-a} was not specified, and +thus enables the default behavior, which starts the suffix length at 2, +and unless @option{-n} or @option{--numeric-suffixes=@var{from}} is +specified, will auto increase the length by 2 as required. @item -d -@itemx --numeric-suffixes +@itemx --numeric-suffixes[=@var{from}] @opindex -d @opindex --numeric-suffixes -Use digits in suffixes rather than lower-case letters. +Use digits in suffixes rather than lower-case letters. The numerical +suffix counts from @var{from} if specified, 0 otherwise. +Note specifying a @var{from} value also disables the default +auto suffix length expansion described above, and so you may also +want to specify @option{-a} to allow suffixes beyond @samp{99}. + +@item --additional-suffix=@var{suffix} +@opindex --additional-suffix +Append an additional @var{suffix} to output file names. @var{suffix} +must not contain slash. @item -e @itemx --elide-empty-files @@ -3069,10 +3105,10 @@ even when this option is specified. @itemx --unbuffered @opindex -u @opindex --unbuffered -Immediately copy input to output in @option{--number r/...} mode, +Immediately copy input to output in @option{--number r/@dots{}} mode, which is a much slower mode of operation. -@itemx --verbose +@item --verbose @opindex --verbose Write a diagnostic just before each output file is opened. @@ -3370,7 +3406,7 @@ Each count is printed right-justified in a field with at least one space between fields so that the numbers and file names normally line up nicely in columns. The width of the count fields varies depending on the inputs, so you should not depend on a particular field width. -However, as a @acronym{GNU} extension, if only one count is printed, +However, as a GNU extension, if only one count is printed, it is guaranteed to be printed without leading spaces. By default, @command{wc} prints three counts: the newline, words, and byte @@ -3425,24 +3461,24 @@ Print only the newline counts. Print only the maximum line lengths. @macro filesZeroFromOption{cmd,withTotalOption,subListOutput} -@itemx --files0-from=@var{file} +@item --files0-from=@var{file} @opindex --files0-from=@var{file} @c This is commented out to avoid a texi2dvi failure. @c texi2dvi (GNU Texinfo 4.11) 1.104 @c @cindex including files from @command{\cmd\} Disallow processing files named on the command line, and instead process those named in file @var{file}; each name being terminated by a zero byte -(@acronym{ASCII} @sc{nul}). +(ASCII NUL). This is useful \withTotalOption\ when the list of file names is so long that it may exceed a command line length limitation. In such cases, running @command{\cmd\} via @command{xargs} is undesirable because it splits the list into pieces and makes @command{\cmd\} print \subListOutput\ for each sublist rather than for the entire list. -One way to produce a list of @acronym{ASCII} @sc{nul} terminated file -names is with @sc{gnu} +One way to produce a list of ASCII NUL terminated file +names is with GNU @command{find}, using its @option{-print0} predicate. -If @var{file} is @samp{-} then the @acronym{ASCII} @sc{nul} terminated +If @var{file} is @samp{-} then the ASCII NUL terminated file names are read from standard input. @end macro @filesZeroFromOption{wc,,a total} @@ -3480,7 +3516,7 @@ is given, file names are also printed (by default). (With the @option{--sysv} option, corresponding file names are printed when there is at least one file argument.) -By default, @sc{gnu} @command{sum} computes checksums using an algorithm +By default, GNU @command{sum} computes checksums using an algorithm compatible with BSD @command{sum} and prints file sizes in units of 1024-byte blocks. @@ -3535,7 +3571,7 @@ by comparing the @command{cksum} output for the received files with the @command{cksum} output for the original files (typically given in the distribution). -The CRC algorithm is specified by the @acronym{POSIX} standard. It is not +The CRC algorithm is specified by the POSIX standard. It is not compatible with the BSD or System V @command{sum} algorithms (see the previous section); it is more robust. @@ -3578,7 +3614,7 @@ md5sum [@var{option}]@dots{} [@var{file}]@dots{} @end example For each @var{file}, @samp{md5sum} outputs the MD5 checksum, a flag -indicating a binary or text input file, and the file name. +indicating binary or text input mode, and the file name. If @var{file} contains a backslash or newline, the line is started with a backslash, and each problematic character in the file name is escaped with a backslash, making the output @@ -3596,8 +3632,8 @@ The program accepts the following options. Also see @ref{Common options}. @cindex binary input files Treat each input file as binary, by reading it in binary mode and outputting a @samp{*} flag. This is the inverse of @option{--text}. -On systems like @acronym{GNU} that do not distinguish between binary -and text files, this option merely flags each input file as binary: +On systems like GNU that do not distinguish between binary +and text files, this option merely flags each input mode as binary: the MD5 checksum is unaffected. This option is the default on systems like MS-DOS that distinguish between binary and text files, except for reading standard input when standard input is a terminal. @@ -3611,7 +3647,7 @@ The input to this mode of @command{md5sum} is usually the output of a prior, checksum-generating run of @samp{md5sum}. Each valid line of input consists of an MD5 checksum, a binary/text flag, and then a file name. -Binary files are marked with @samp{*}, text with @samp{ }. +Binary mode is indicated with @samp{*}, text with @samp{ } (space). For each such line, @command{md5sum} reads the named file and computes its MD5 checksum. Then, if the computed message digest does not match the one on the line with the file name, the file is noted as having @@ -3626,7 +3662,7 @@ an MD5 checksum inconsistent with the associated file, or if no valid line is found, @command{md5sum} exits with nonzero status. Otherwise, it exits successfully. -@itemx --quiet +@item --quiet @opindex --quiet @cindex verifying MD5 checksums This option is useful only when verifying checksums. @@ -3635,7 +3671,7 @@ checked file. Files that fail the verification are reported in the default one-line-per-file format. If there is any checksum mismatch, print a warning summarizing the failures to standard error. -@itemx --status +@item --status @opindex --status @cindex verifying MD5 checksums This option is useful only when verifying checksums. @@ -3647,6 +3683,17 @@ If all listed files are readable and are consistent with the associated MD5 checksums, exit successfully. Otherwise exit with a status code indicating there was a failure. +@item --tag +@opindex --tag +@cindex BSD output +Output BSD style checksums, which indicate the checksum algorithm used. +As a GNU extension, file names with problematic characters +are escaped as described above, with the same escaping indicator of @samp{\} +at the start of the line, being used. +The @option{--tag} option implies binary mode, and is disallowed with +@option{--text} mode as supporting that would unnecessarily complicate +the output format, while providing little benefit. + @item -t @itemx --text @opindex -t @@ -3654,10 +3701,10 @@ indicating there was a failure. @cindex text input files Treat each input file as text, by reading it in text mode and outputting a @samp{ } flag. This is the inverse of @option{--binary}. -This option is the default on systems like @acronym{GNU} that do not +This option is the default on systems like GNU that do not distinguish between binary and text files. On other systems, it is the default for reading standard input when standard input is a -terminal. +terminal. This mode is never defaulted to if @option{--tag} is used. @item -w @itemx --warn @@ -3668,6 +3715,13 @@ When verifying checksums, warn about improperly formatted MD5 checksum lines. This option is useful only if all but a few lines in the checked input are valid. +@item --strict +@opindex --strict +@cindex verifying MD5 checksums +When verifying checksums, +if one or more input line is invalid, +exit nonzero after all warnings have been issued. + @end table @exitstatus @@ -3824,19 +3878,19 @@ in their original relative order. The @option{--unique} @vindex LC_COLLATE Unless otherwise specified, all comparisons use the character collating sequence specified by the @env{LC_COLLATE} locale.@footnote{If you -use a non-@acronym{POSIX} locale (e.g., by setting @env{LC_ALL} +use a non-POSIX locale (e.g., by setting @env{LC_ALL} to @samp{en_US}), then @command{sort} may produce output that is sorted differently than you're accustomed to. In that case, set the @env{LC_ALL} -environment variable to @samp{C}. Note that setting only @env{LC_COLLATE} +environment variable to @samp{C}@. Note that setting only @env{LC_COLLATE} has two problems. First, it is ineffective if @env{LC_ALL} is also set. Second, it has undefined behavior if @env{LC_CTYPE} (or @env{LANG}, if @env{LC_CTYPE} is unset) is set to an incompatible value. For example, you get undefined behavior if @env{LC_CTYPE} is @code{ja_JP.PCK} but @env{LC_COLLATE} is @code{en_US.UTF-8}.} -@sc{gnu} @command{sort} (as specified for all @sc{gnu} utilities) has no +GNU @command{sort} (as specified for all GNU utilities) has no limit on input line length or restrictions on bytes allowed within lines. -In addition, if the final byte of an input file is not a newline, @sc{gnu} +In addition, if the final byte of an input file is not a newline, GNU @command{sort} silently supplies one. A line's trailing newline is not part of the line for comparison purposes. @@ -3859,7 +3913,7 @@ The following options affect the ordering of output lines. They may be specified globally or as part of a specific key field. If no key fields are specified, global options apply to comparison of entire lines; otherwise the global options are inherited by key fields that do -not specify any special options of their own. In pre-@acronym{POSIX} +not specify any special options of their own. In pre-POSIX versions of @command{sort}, global options affect only later key fields, so portable shell scripts should specify global options first. @@ -3887,7 +3941,7 @@ positions specified in keys with the @option{-k} option. @vindex LC_CTYPE Sort in @dfn{phone directory} order: ignore all characters except letters, digits and blanks when sorting. -By default letters and digits are those of @acronym{ASCII} and a blank +By default letters and digits are those of ASCII and a blank is a space or a tab, but the @env{LC_CTYPE} locale can change this. @item -f @@ -3901,8 +3955,8 @@ Fold lowercase characters into the equivalent uppercase characters when comparing so that, for example, @samp{b} and @samp{B} sort as equal. The @env{LC_CTYPE} locale determines character types. When used with @option{--unique} those lower case equivalent lines are -thrown away. (There is currently no way to throw away the upper case -equivalent instead. (Any @option{--reverse} given would only affect +thrown away. (There is currently no way to throw away the upper case +equivalent instead. (Any @option{--reverse} given would only affect the final result, after the throwing away.)) @item -g @@ -3945,17 +3999,17 @@ converting to floating point. @cindex human numeric sort @vindex LC_NUMERIC Sort numerically, first by numeric sign (negative, zero, or positive); -then by @acronym{SI} suffix (either empty, or @samp{k} or @samp{K}, or +then by SI suffix (either empty, or @samp{k} or @samp{K}, or one of @samp{MGTPEZY}, in that order; @pxref{Block size}); and finally by numeric value. For example, @samp{1023M} sorts before @samp{1G} -because @samp{M} (mega) precedes @samp{G} (giga) as an @acronym{SI} +because @samp{M} (mega) precedes @samp{G} (giga) as an SI suffix. This option sorts values that are consistently scaled to the nearest suffix, regardless of whether suffixes denote powers of 1000 or 1024, and it therefore sorts the output of any single invocation of the @command{df}, @command{du}, or @command{ls} commands that are invoked with their @option{--human-readable} or @option{--si} options. The syntax for numbers is the same as for the @option{--numeric-sort} -option; the @acronym{SI} suffix must immediately follow the number. +option; the SI suffix must immediately follow the number. @item -i @itemx --ignore-nonprinting @@ -3979,7 +4033,7 @@ This option has no effect if the stronger @option{--dictionary-order} @vindex LC_TIME An initial string, consisting of any amount of blanks, followed by a month name abbreviation, is folded to UPPER case and -compared in the order @samp{JAN} < @samp{FEB} < @dots{} < @samp{DEC}. +compared in the order @samp{JAN} < @samp{FEB} < @dots{} < @samp{DEC}@. Invalid names compare low to valid names. The @env{LC_TIME} locale category determines the month spellings. By default a blank is a space or a tab, but the @env{LC_CTYPE} locale @@ -4106,8 +4160,8 @@ a temporary file, which is then used as an input in a subsequent merge. A large value of @var{nmerge} may improve merge performance and decrease temporary storage utilization at the expense of increased memory usage -and I/0. Conversely a small value of @var{nmerge} may reduce memory -requirements and I/0 at the expense of temporary storage consumption and +and I/O@. Conversely a small value of @var{nmerge} may reduce memory +requirements and I/O at the expense of temporary storage consumption and merge performance. The value of @var{nmerge} must be at least 2. The default value is @@ -4130,7 +4184,7 @@ silently uses a smaller value. Write output to @var{output-file} instead of standard output. Normally, @command{sort} reads all input before opening @var{output-file}, so you can safely sort a file in place by using -commands like @code{sort -o F F} and @code{cat F | sort -o F}. +commands like @code{sort -o F F} and @code{cat F | sort -o F}@. However, @command{sort} with @option{--merge} (@option{-m}) can open the output file before reading all input, so a command like @code{cat F | sort -m -o F - G} is not safe as @command{sort} might start @@ -4138,7 +4192,7 @@ writing @file{F} before @command{cat} is done reading it. @vindex POSIXLY_CORRECT On newer systems, @option{-o} cannot appear after an input file if -@env{POSIXLY_CORRECT} is set, e.g., @samp{sort F -o F}. Portable +@env{POSIXLY_CORRECT} is set, e.g., @samp{sort F -o F}@. Portable scripts should specify @option{-o @var{output-file}} before any input files. @@ -4170,7 +4224,7 @@ Use a main-memory sort buffer of the given @var{size}. By default, @var{size} to be interpreted as a percentage of physical memory. Appending @samp{K} multiplies @var{size} by 1024 (the default), @samp{M} by 1,048,576, @samp{G} by 1,073,741,824, and so on for -@samp{T}, @samp{P}, @samp{E}, @samp{Z}, and @samp{Y}. Appending +@samp{T}, @samp{P}, @samp{E}, @samp{Z}, and @samp{Y}@. Appending @samp{b} causes @var{size} to be interpreted as a byte count, with no multiplication. @@ -4200,7 +4254,7 @@ However, fields that extend to the end of the line, as @option{-k 2}, or fields consisting of a range, as @option{-k 2,3}, retain the field separators present between the endpoints of the range. -To specify @acronym{ASCII} @sc{nul} as the field separator, +To specify ASCII NUL as the field separator, use the two-character string @samp{\0}, e.g., @samp{sort -t '\0'}. @item -T @var{tempdir} @@ -4249,9 +4303,9 @@ uniq} inspects the entire line. @xref{uniq invocation}. @opindex -z @opindex --zero-terminated @cindex process zero-terminated items -Delimit items with a zero byte rather than a newline (@acronym{ASCII} @sc{lf}). -I.E. treat input as items separated by @acronym{ASCII} @sc{nul} -and terminate output items with @acronym{ASCII} @sc{nul}. +Delimit items with a zero byte rather than a newline (ASCII LF). +I.e., treat input as items separated by ASCII NUL +and terminate output items with ASCII NUL. This option can be useful in conjunction with @samp{perl -0} or @samp{find -print0} and @samp{xargs -0} which do the same in order to reliably handle arbitrary file names (even those containing blanks @@ -4264,9 +4318,9 @@ or other special characters). Historical (BSD and System V) implementations of @command{sort} have differed in their interpretation of some options, particularly @option{-b}, @option{-f}, and @option{-n}. -@sc{gnu} sort follows the @acronym{POSIX} +GNU sort follows the POSIX behavior, which is usually (but not always!) like the System V behavior. -According to @acronym{POSIX}, @option{-n} no longer implies @option{-b}. For +According to POSIX, @option{-n} no longer implies @option{-b}. For consistency, @option{-M} has been changed in the same way. This may affect the meaning of character positions in field specifications in obscure cases. The only fix is to add an explicit @option{-b}. @@ -4321,7 +4375,7 @@ sort -n -r @end example @item -Run no more that 4 sorts concurrently, using a buffer size of 10M. +Run no more than 4 sorts concurrently, using a buffer size of 10M. @example sort --parallel=4 -S 10M @@ -4441,7 +4495,7 @@ by the sort operation. @c @end example @item -Use the common @acronym{DSU, Decorate Sort Undecorate} idiom to +Use the common DSU, Decorate Sort Undecorate idiom to sort lines according to their length. @example @@ -4701,12 +4755,12 @@ This is equivalent to @option{--all-repeated} (@option{-D}). @item prepend Output a newline before each group of repeated lines. With @option{--zero-terminated} (@option{-z}), use a zero -byte (@acronym{ASCII} @sc{nul}) instead of a newline. +byte (ASCII NUL) instead of a newline. @item separate Separate groups of repeated lines with a single newline. With @option{--zero-terminated} (@option{-z}), use a zero -byte (@acronym{ASCII} @sc{nul}) instead of a newline. +byte (ASCII NUL) instead of a newline. This is the same as using @samp{prepend}, except that no delimiter is inserted before the first group, and hence may be better suited for output direct to users. @@ -4717,7 +4771,7 @@ two or more consecutive blank lines, then the output is ambiguous. To avoid that, filter the input through @samp{tr -s '\n'} to replace each sequence of consecutive newlines with a single newline. -This is a @sc{gnu} extension. +This is a GNU extension. @c FIXME: give an example showing *how* it's useful @item -u @@ -4772,7 +4826,7 @@ contains lines unique to @var{file1}, column two contains lines unique to @var{file2}, and column three contains lines common to both files. Columns are separated by a single TAB character. @c FIXME: when there's an option to supply an alternative separator -@c string, append `by default' to the above sentence. +@c string, append "by default" to the above sentence. @opindex -1 @opindex -2 @@ -4839,15 +4893,15 @@ ptx -G [@var{option} @dots{}] [@var{input} [@var{output}]] @end example The @option{-G} (or its equivalent: @option{--traditional}) option disables -all @sc{gnu} extensions and reverts to traditional mode, thus introducing some +all GNU extensions and reverts to traditional mode, thus introducing some limitations and changing several of the program's default option values. -When @option{-G} is not specified, @sc{gnu} extensions are always enabled. -@sc{gnu} extensions to @command{ptx} are documented wherever appropriate in this -document. For the full list, see @xref{Compatibility in ptx}. +When @option{-G} is not specified, GNU extensions are always enabled. +GNU extensions to @command{ptx} are documented wherever appropriate in this +document. @xref{Compatibility in ptx}, for the full list. Individual options are explained in the following sections. -When @sc{gnu} extensions are enabled, there may be zero, one or several +When GNU extensions are enabled, there may be zero, one or several @var{file}s after the options. If there is no @var{file}, the program reads the standard input. If there is one or several @var{file}s, they give the name of input files which are all read in turn, as if all the @@ -4857,7 +4911,7 @@ file names and line numbers refer to individual text input files. In all cases, the program outputs the permuted index to the standard output. -When @sc{gnu} extensions are @emph{not} enabled, that is, when the program +When GNU extensions are @emph{not} enabled, that is, when the program operates in traditional mode, there may be zero, one or two parameters besides the options. If there are no parameters, the program reads the standard input and outputs the permuted index to the standard output. @@ -4867,7 +4921,7 @@ respectively the name of the @var{input} file to read and the name of the @var{output} file to produce. @emph{Be very careful} to note that, in this case, the contents of file given by the second parameter is destroyed. This behavior is dictated by System V @command{ptx} -compatibility; @sc{gnu} Standards normally discourage output parameters not +compatibility; GNU Standards normally discourage output parameters not introduced by an option. Note that for @emph{any} file named as the value of an option or as an @@ -4891,7 +4945,7 @@ convention more than once per program invocation. @item -G @itemx --traditional -As already explained, this option disables all @sc{gnu} extensions to +As already explained, this option disables all GNU extensions to @command{ptx} and switches to traditional mode. @item --help @@ -4912,10 +4966,10 @@ processing. @c FIXME: People don't necessarily know what an IBM-PC was these days. As it is set up now, the program assumes that the input file is coded -using 8-bit @acronym{ISO} 8859-1 code, also known as Latin-1 character set, +using 8-bit ISO 8859-1 code, also known as Latin-1 character set, @emph{unless} it is compiled for MS-DOS, in which case it uses the -character set of the IBM-PC@. (@sc{gnu} @command{ptx} is not known to work on -smaller MS-DOS machines anymore.) Compared to 7-bit @acronym{ASCII}, the set +character set of the IBM-PC@. (GNU @command{ptx} is not known to work on +smaller MS-DOS machines anymore.) Compared to 7-bit ASCII, the set of characters which are letters is different; this alters the behavior of regular expression matching. Thus, the default regular expression for a keyword allows foreign or diacriticized letters. Keyword sorting, @@ -4947,9 +5001,9 @@ is not part of the Break file is a word constituent. If both options @option{-b} and @option{-W} are specified, then @option{-W} has precedence and @option{-b} is ignored. -When @sc{gnu} extensions are enabled, the only way to avoid newline as a +When GNU extensions are enabled, the only way to avoid newline as a break character is to write all the break characters in the file with no -newline at all, not even at the end of the file. When @sc{gnu} extensions +newline at all, not even at the end of the file. When GNU extensions are disabled, spaces, tabs and newlines are always considered as break characters even if not included in the Break file. @@ -4980,14 +5034,15 @@ if it is listed in the Only file and not in the Ignore file. On each input line, the leading sequence of non-white space characters will be taken to be a reference that has the purpose of identifying this input -line in the resulting permuted index. For more information about reference -production, see @xref{Output formatting in ptx}. +line in the resulting permuted index. +@xref{Output formatting in ptx}, +for more information about reference production. Using this option changes the default value for option @option{-S}. Using this option, the program does not try very hard to remove references from contexts in output, but it succeeds in doing so @emph{when} the context ends exactly at the newline. If option -@option{-r} is used with @option{-S} default value, or when @sc{gnu} extensions +@option{-r} is used with @option{-S} default value, or when GNU extensions are disabled, this condition is always met and references are completely excluded from the output contexts. @@ -4998,15 +5053,15 @@ This option selects which regular expression will describe the end of a line or the end of a sentence. In fact, this regular expression is not the only distinction between end of lines or end of sentences, and input line boundaries have no special significance outside this option. By -default, when @sc{gnu} extensions are enabled and if @option{-r} option is not +default, when GNU extensions are enabled and if @option{-r} option is not used, end of sentences are used. In this case, this @var{regex} is -imported from @sc{gnu} Emacs: +imported from GNU Emacs: @example [.?!][]\"')@}]*\\($\\|\t\\| \\)[ \t\n]* @end example -Whenever @sc{gnu} extensions are disabled or if @option{-r} option is used, end +Whenever GNU extensions are disabled or if @option{-r} option is used, end of lines are used; in this case, the default @var{regexp} is just: @example @@ -5038,8 +5093,8 @@ corresponding characters by @command{ptx} itself. @itemx --word-regexp=@var{regexp} This option selects which regular expression will describe each keyword. -By default, if @sc{gnu} extensions are enabled, a word is a sequence of -letters; the @var{regexp} used is @samp{\w+}. When @sc{gnu} extensions are +By default, if GNU extensions are enabled, a word is a sequence of +letters; the @var{regexp} used is @samp{\w+}. When GNU extensions are disabled, a word is by default anything which ends with a space, a tab or a newline; the @var{regexp} used is @samp{[^ \t\n]+}. @@ -5059,14 +5114,14 @@ the corresponding characters by @command{ptx} itself. Output format is mainly controlled by the @option{-O} and @option{-T} options described in the table below. When neither @option{-O} nor @option{-T} are -selected, and if @sc{gnu} extensions are enabled, the program chooses an +selected, and if GNU extensions are enabled, the program chooses an output format suitable for a dumb terminal. Each keyword occurrence is output to the center of one line, surrounded by its left and right contexts. Each field is properly justified, so the concordance output can be readily observed. As a special feature, if automatic references are selected by option @option{-A} and are output before the left context, that is, if option @option{-R} is @emph{not} selected, then -a colon is added after the reference; this nicely interfaces with @sc{gnu} +a colon is added after the reference; this nicely interfaces with GNU Emacs @code{next-error} processing. In this default output format, each white space character, like newline and tab, is merely changed to exactly one space, with no special attempt to compress consecutive @@ -5089,7 +5144,7 @@ output line. Select the maximum output width of each final line. If references are used, they are included or excluded from the maximum output width -depending on the value of option @option{-R}. If this option is not +depending on the value of option @option{-R}@. If this option is not selected, that is, when references are output before the left context, the maximum output width takes into account the maximum length of all references. If this option is selected, that is, when references are @@ -5119,7 +5174,7 @@ context. For any other output format, option @option{-R} is ignored, with one exception: with @option{-R} the width of references is @emph{not} taken into account in total output width given by @option{-w}. -This option is automatically selected whenever @sc{gnu} extensions are +This option is automatically selected whenever GNU extensions are disabled. @item -F @var{string} @@ -5128,14 +5183,14 @@ disabled. This option will request that any truncation in the output be reported using the string @var{string}. Most output fields theoretically extend towards the beginning or the end of the current line, or current -sentence, as selected with option @option{-S}. But there is a maximum +sentence, as selected with option @option{-S}@. But there is a maximum allowed output line width, changeable through option @option{-w}, which is further divided into space for various output fields. When a field has to be truncated because it cannot extend beyond the beginning or the end of the current line to fit in, then a truncation occurs. By default, the string used is a single slash, as in @option{-F /}. -@var{string} may have more than one character, as in @option{-F ...}. +@var{string} may have more than one character, as in @option{-F @dots{}}. Also, in the particular case when @var{string} is empty (@option{-F ""}), truncation flagging is disabled, and no truncation marks are appended in this case. @@ -5162,7 +5217,7 @@ processing. Each output line will look like: @end smallexample so it will be possible to write a @samp{.xx} roff macro to take care of -the output typesetting. This is the default output format when @sc{gnu} +the output typesetting. This is the default output format when GNU extensions are disabled. Option @option{-M} can be used to change @samp{xx} to another macro name. @@ -5199,7 +5254,7 @@ Circumflex and tilde diacritical marks produce the sequence @code{^\@{ @}} and @code{~\@{ @}} respectively. Other diacriticized characters of the underlying character set produce an appropriate @TeX{} sequence as far as possible. The other non-graphical characters, like newline and tab, -and all other characters which are not part of @acronym{ASCII}, are merely +and all other characters which are not part of ASCII, are merely changed to exactly one space, with no special attempt to compress consecutive spaces. Let me know how to improve this special character processing for @TeX{}. @@ -5208,13 +5263,13 @@ processing for @TeX{}. @node Compatibility in ptx -@subsection The @sc{gnu} extensions to @command{ptx} +@subsection The GNU extensions to @command{ptx} This version of @command{ptx} contains a few features which do not exist in System V @command{ptx}. These extra features are suppressed by using the @option{-G} command line option, unless overridden by other command line -options. Some @sc{gnu} extensions cannot be recovered by overriding, so the -simple rule is to avoid @option{-G} if you care about @sc{gnu} extensions. +options. Some GNU extensions cannot be recovered by overriding, so the +simple rule is to avoid @option{-G} if you care about GNU extensions. Here are the differences between this program and System V @command{ptx}. @itemize @bullet @@ -5227,8 +5282,8 @@ or, if a second @var{file} parameter is given on the command, to that @var{file}. Having output parameters not introduced by options is a dangerous -practice which @sc{gnu} avoids as far as possible. So, for using @command{ptx} -portably between @sc{gnu} and System V, you should always use it with a +practice which GNU avoids as far as possible. So, for using @command{ptx} +portably between GNU and System V, you should always use it with a single input file, and always expect the result on standard output. You might also want to automatically configure in a @option{-G} option to @command{ptx} calls in products using @command{ptx}, if the configurator finds @@ -5237,9 +5292,9 @@ that the installed @command{ptx} accepts @option{-G}. @item The only options available in System V @command{ptx} are options @option{-b}, @option{-f}, @option{-g}, @option{-i}, @option{-o}, @option{-r}, @option{-t} and -@option{-w}. All other options are @sc{gnu} extensions and are not repeated in +@option{-w}. All other options are GNU extensions and are not repeated in this enumeration. Moreover, some options have a slightly different -meaning when @sc{gnu} extensions are enabled, as explained below. +meaning when GNU extensions are enabled, as explained below. @item By default, concordance output is not formatted for @command{troff} or @@ -5248,29 +5303,30 @@ or @command{nroff} output may still be selected through option @option{-O}. @item Unless @option{-R} option is used, the maximum reference width is -subtracted from the total output line width. With @sc{gnu} extensions +subtracted from the total output line width. With GNU extensions disabled, width of references is not taken into account in the output line width computations. @item -All 256 bytes, even @acronym{ASCII} @sc{nul} bytes, are always read and -processed from input file with no adverse effect, even if @sc{gnu} extensions -are disabled. However, System V @command{ptx} does not accept 8-bit characters, -a few control characters are rejected, and the tilde @kbd{~} is also rejected. +All 256 bytes, even ASCII NUL bytes, are always read and +processed from input file with no adverse effect, even if GNU extensions +are disabled. However, System V @command{ptx} does not accept 8-bit +characters, a few control characters are rejected, and the tilde +@kbd{~} is also rejected. @item -Input line length is only limited by available memory, even if @sc{gnu} +Input line length is only limited by available memory, even if GNU extensions are disabled. However, System V @command{ptx} processes only the first 200 characters in each line. @item The break (non-word) characters default to be every character except all -letters of the underlying character set, diacriticized or not. When @sc{gnu} +letters of the underlying character set, diacriticized or not. When GNU extensions are disabled, the break characters default to space, tab and newline only. @item -The program makes better use of output line width. If @sc{gnu} extensions +The program makes better use of output line width. If GNU extensions are disabled, the program rather tries to imitate System V @command{ptx}, but still, there are some slight disposition glitches this program does not completely reproduce. @@ -5558,7 +5614,7 @@ ranges of selected bytes. @item --complement @opindex --complement -This option is a @acronym{GNU} extension. +This option is a GNU extension. Select for printing the complement of the bytes, characters or fields selected with the @option{-b}, @option{-c} or @option{-f} options. In other words, do @emph{not} print the bytes, characters or fields @@ -5674,7 +5730,7 @@ do so consistently between @command{join} and @command{sort}. If @samp{join -t ''} is specified then the whole line is considered which matches the default operation of sort. -If the input has no unpairable lines, a @acronym{GNU} extension is +If the input has no unpairable lines, a GNU extension is available; the sort order can be any order that considers two fields to be equal if and only if the sort comparison described above considers them to be equal. For example: @@ -5726,12 +5782,12 @@ Do not check that both input files are in sorted order. This is the default. @item -e @var{string} @opindex -e Replace those output fields that are missing in the input with @var{string}. -I.E. missing fields specified with the @option{-12jo} options. +I.e., missing fields specified with the @option{-12jo} options. @item --header @opindex --header -Treat the first line of each input file as a header line. The header lines will -be joined and printed as the first output line. If @option{-o} is used to +Treat the first line of each input file as a header line. The header lines +will be joined and printed as the first output line. If @option{-o} is used to specify output format, the header line will be printed according to the specified format. The header lines will not be checked for ordering even if @option{--check-order} is specified. Also if the header lines from each file @@ -5776,7 +5832,7 @@ to the join field. However, when printing unpairable lines (using either of the @option{-a} or @option{-v} options), there is no way to specify the join field using @var{m.n} in @var{field-list} if there are unpairable lines in both files. -To give @command{join} that functionality, @acronym{POSIX} invented the @samp{0} +To give @command{join} that functionality, POSIX invented the @samp{0} field specification notation. The elements in @var{field-list} @@ -5794,7 +5850,7 @@ Treat as significant each occurrence of @var{char} in the input file. Use @samp{sort -t @var{char}}, without the @option{-b} option of @samp{sort}, to produce this ordering. If @samp{join -t ''} is specified, the whole line is considered, matching the default operation of sort. -If @samp{-t '\0'} is specified then the @acronym{ASCII} @sc{nul} +If @samp{-t '\0'} is specified then the ASCII NUL character is used to delimit the fields. @item -v @var{file-number} @@ -5927,7 +5983,7 @@ from @var{m} through @var{n}, in ascending order. @var{m} should collate before @var{n}; if it doesn't, an error results. As an example, @samp{0-9} is the same as @samp{0123456789}. -@sc{gnu} @command{tr} does not support the System V syntax that uses square +GNU @command{tr} does not support the System V syntax that uses square brackets to enclose ranges. Translations specified in that format sometimes work as expected, since the brackets are often transliterated to themselves. However, they should be avoided because they sometimes @@ -5935,10 +5991,10 @@ behave unexpectedly. For example, @samp{tr -d '[0-9]'} deletes brackets as well as digits. Many historically common and even accepted uses of ranges are not -portable. For example, on @acronym{EBCDIC} hosts using the @samp{A-Z} +portable. For example, on EBCDIC hosts using the @samp{A-Z} range will not do what most would expect because @samp{A} through @samp{Z} -are not contiguous as they are in @acronym{ASCII}. -If you can rely on a @acronym{POSIX} compliant version of @command{tr}, then +are not contiguous as they are in ASCII@. +If you can rely on a POSIX compliant version of @command{tr}, then the best way to work around this is to use character classes (see below). Otherwise, it is most portable (and most ugly) to enumerate the members of the ranges. @@ -6015,7 +6071,7 @@ The syntax @samp{[=@var{c}=]} expands to all of the characters that are equivalent to @var{c}, in no particular order. Equivalence classes are a relatively recent invention intended to support non-English alphabets. But there seems to be no standard way to define them or determine their -contents. Therefore, they are not fully implemented in @sc{gnu} @command{tr}; +contents. Therefore, they are not fully implemented in GNU @command{tr}; each character's equivalence class consists only of that character, which is of no particular use. @@ -6058,14 +6114,14 @@ typically have the same length. If @var{set1} is shorter than @var{set2}, the extra characters at the end of @var{set2} are ignored. On the other hand, making @var{set1} longer than @var{set2} is not -portable; @acronym{POSIX} says that the result is undefined. In this situation, +portable; POSIX says that the result is undefined. In this situation, BSD @command{tr} pads @var{set2} to the length of @var{set1} by repeating the last character of @var{set2} as many times as necessary. System V @command{tr} truncates @var{set1} to the length of @var{set2}. -By default, @sc{gnu} @command{tr} handles this case like BSD @command{tr}. +By default, GNU @command{tr} handles this case like BSD @command{tr}. When the @option{--truncate-set1} (@option{-t}) option is given, -@sc{gnu} @command{tr} handles this case like the System V @command{tr} +GNU @command{tr} handles this case like the System V @command{tr} instead. This option is ignored for operations other than translation. Acting like System V @command{tr} in this case breaks the relatively common @@ -6083,7 +6139,7 @@ newlines. @noindent By the way, the above idiom is not portable because it uses ranges, and it assumes that the octal code for newline is 012. -Assuming a @acronym{POSIX} compliant @command{tr}, here is a better +Assuming a POSIX compliant @command{tr}, here is a better way to write it: @example @@ -6261,7 +6317,7 @@ characters) on each line to spaces. @command{unexpand} writes the contents of each given @var{file}, or standard input if none are given or for a @var{file} of @samp{-}, to standard output, converting blanks at the beginning of each line into -as many tab characters as needed. In the default @acronym{POSIX} +as many tab characters as needed. In the default POSIX locale, a @dfn{blank} is a space or a tab; other locales may specify additional blank characters. Synopsis: @@ -6340,7 +6396,7 @@ directory, acting as if it had been invoked with a single argument of @samp{.}. @vindex LC_ALL By default, the output is sorted alphabetically, according to the locale -settings in effect.@footnote{If you use a non-@acronym{POSIX} +settings in effect.@footnote{If you use a non-POSIX locale (e.g., by setting @env{LC_ALL} to @samp{en_US}), then @command{ls} may produce output that is sorted differently than you're accustomed to. In that case, set the @env{LC_ALL} environment variable to @samp{C}.} @@ -6433,7 +6489,7 @@ command line unless the @option{--dereference-command-line} (@option{-H}), If a command line argument specifies a symbolic link, show information for the file the link references rather than for the link itself. -@itemx --dereference-command-line-symlink-to-dir +@item --dereference-command-line-symlink-to-dir @opindex --dereference-command-line-symlink-to-dir @cindex symbolic links, dereferencing Do not dereference symbolic links, with one exception: @@ -6621,7 +6677,7 @@ $ ls -blog --dired 'a b' If you use a quoting style that adds quote marks (e.g., @option{--quoting-style=c}), then the offsets include the quote marks. So beware that the user may select the quoting style via the environment -variable @env{QUOTING_STYLE}. Hence, applications using @option{--dired} +variable @env{QUOTING_STYLE}@. Hence, applications using @option{--dired} should either specify an explicit @option{--quoting-style=literal} option (aka @option{-N} or @option{--literal}) on the command line, or else be prepared to parse the escaped names. @@ -6641,7 +6697,7 @@ Produce long format directory listings, but don't display owner information. @opindex -G @opindex --no-group Inhibit display of group information in a long format directory listing. -(This is the default in some non-@sc{gnu} versions of @command{ls}, so we +(This is the default in some non-GNU versions of @command{ls}, so we provide this option for compatibility.) @optHumanReadable @@ -6823,7 +6879,7 @@ to the left of the size column. @cindex sorting @command{ls} output These options change the order in which @command{ls} sorts the information it outputs. By default, sorting is done by character code -(e.g., @acronym{ASCII} order). +(e.g., ASCII order). @table @samp @@ -6955,7 +7011,7 @@ which has some caveats worth noting. @itemize @bullet @item @env{LC_COLLATE} is ignored, which means @samp{ls -v} and @samp{sort -V} will sort non-numeric prefixes as if the @env{LC_COLLATE} locale category -was set to @samp{C}. +was set to @samp{C}@. @item Some suffixes will not be matched by the regular expression mentioned above. Consequently these examples may not sort as you expect: @@ -6994,7 +7050,7 @@ output is not a terminal. List files in columns, sorted vertically. This is the default for @command{ls} if standard output is a terminal. It is always the default for the @command{dir} program. -@sc{gnu} @command{ls} uses variable width columns to display as many files as +GNU @command{ls} uses variable width columns to display as many files as possible in the fewest lines. @item --color [=@var{when}] @@ -7020,6 +7076,23 @@ Piping a colorized listing through a pager like @command{more} or @command{less} usually produces unreadable results. However, using @code{more -f} does seem to work. +@vindex LS_COLORS +@vindex SHELL @r{environment variable, and color} +Note that using the @option{--color} option may incur a noticeable +performance penalty when run in a directory with very many entries, +because the default settings require that @command{ls} @code{stat} every +single file it lists. +However, if you would like most of the file-type coloring +but can live without the other coloring options (e.g., +executable, orphan, sticky, other-writable, capability), use +@command{dircolors} to set the @env{LS_COLORS} environment variable like this, +@example +eval $(dircolors -p | perl -pe \ + 's/^((CAP|S[ET]|O[TR]|M|E)\w+).*/$1 00/' | dircolors -) +@end example +and on a @code{dirent.d_type}-capable file system, @command{ls} +will perform only one @code{stat} call per command line argument. + @item -F @itemx --classify @itemx --indicator-style=classify @@ -7069,10 +7142,19 @@ Append @samp{*} for executable regular files, otherwise behave as for @end table @item -k +@itemx --kibibytes @opindex -k -Print file sizes in 1024-byte blocks, overriding the default block -size (@pxref{Block size}). -This option is equivalent to @option{--block-size=1K}. +@opindex --kibibytes +Set the default block size to its normal value of 1024 bytes, +overriding any contrary specification in environment variables +(@pxref{Block size}). This option is in turn overridden by the +@option{--block-size}, @option{-h} or @option{--human-readable}, and +@option{--si} options. + +The @option{-k} or @option{--kibibytes} option affects the +per-directory block count written by the @option{-l} and similar +options, and the size written by the @option{-s} or @option{--size} +option. It does not affect the file size written by @option{-l}. @item -m @itemx --format=commas @@ -7109,7 +7191,7 @@ Assume that each tab stop is @var{cols} columns wide. The default is 8. @c FIXME: remove in 2009, if Apple Terminal has been fixed for long enough. Some terminal emulators (at least Apple Terminal 1.5 (133) from Mac OS X 10.4.8) do not properly align columns to the right of a TAB following a -non-@acronym{ASCII} byte. If you use such a terminal emulator, use the +non-ASCII byte. If you use such a terminal emulator, use the @option{-T0} option or put @code{TABSIZE=0} in your environment to tell @command{ls} to align using spaces, not tabs. @@ -7134,6 +7216,7 @@ a date like @samp{Mar 30@ @ 2002} for non-recent timestamps, and a date-without-year and time like @samp{Mar 30 23:45} for recent timestamps. This format can change depending on the current locale as detailed below. +@cindex clock skew A timestamp is considered to be @dfn{recent} if it is less than six months old, and is not dated in the future. If a timestamp dated today is not listed in recent form, the timestamp is in the future, @@ -7171,25 +7254,25 @@ files; if you want output columns to line up, you may need to insert spaces in one of the two formats. @item full-iso -List timestamps in full using @acronym{ISO} 8601 date, time, and time zone +List timestamps in full using ISO 8601 date, time, and time zone format with nanosecond precision, e.g., @samp{2002-03-30 23:45:56.477817180 -0700}. This style is equivalent to @samp{+%Y-%m-%d %H:%M:%S.%N %z}. This is useful because the time output includes all the information that is available from the operating system. For example, this can help -explain @command{make}'s behavior, since @acronym{GNU} @command{make} +explain @command{make}'s behavior, since GNU @command{make} uses the full timestamp to determine whether a file is out of date. @item long-iso -List @acronym{ISO} 8601 date and time in minutes, e.g., +List ISO 8601 date and time in minutes, e.g., @samp{2002-03-30 23:45}. These timestamps are shorter than @samp{full-iso} timestamps, and are usually good enough for everyday work. This style is equivalent to @samp{+%Y-%m-%d %H:%M}. @item iso -List @acronym{ISO} 8601 dates for non-recent timestamps (e.g., -@samp{2002-03-30@ }), and @acronym{ISO} 8601 month, day, hour, and +List ISO 8601 dates for non-recent timestamps (e.g., +@samp{2002-03-30@ }), and ISO 8601 month, day, hour, and minute for recent timestamps (e.g., @samp{03-30 23:45}). These timestamps are uglier than @samp{long-iso} timestamps, but they carry nearly the same information in a smaller space and their brevity helps @@ -7213,7 +7296,7 @@ are harder for programs to parse because locale conventions vary so widely, but they are easier for many people to read. The @env{LC_TIME} locale category specifies the timestamp format. The -default @acronym{POSIX} locale uses timestamps like @samp{Mar 30@ +default POSIX locale uses timestamps like @samp{Mar 30@ @ 2002} and @samp{Mar 30 23:45}; in this locale, the following two @command{ls} invocations are equivalent: @@ -7232,21 +7315,21 @@ and might generate timestamps like @samp{30. M@"ar 2002@ } and @item posix-@var{style} @vindex LC_TIME -List @acronym{POSIX}-locale timestamps if the @env{LC_TIME} locale -category is @acronym{POSIX}, @var{style} timestamps otherwise. For +List POSIX-locale timestamps if the @env{LC_TIME} locale +category is POSIX, @var{style} timestamps otherwise. For example, the @samp{posix-long-iso} style lists timestamps like @samp{Mar 30@ @ 2002} and @samp{Mar 30 23:45} when in -the @acronym{POSIX} locale, and like @samp{2002-03-30 23:45} otherwise. +the POSIX locale, and like @samp{2002-03-30 23:45} otherwise. @end table @end table @vindex TIME_STYLE You can specify the default value of the @option{--time-style} option with the environment variable @env{TIME_STYLE}; if @env{TIME_STYLE} is not set -the default style is @samp{locale}. @acronym{GNU} Emacs 21.3 and +the default style is @samp{locale}. GNU Emacs 21.3 and later use the @option{--dired} option and therefore can parse any date format, but if you are using Emacs 21.1 or 21.2 and specify a -non-@acronym{POSIX} locale you may need to set +non-POSIX locale you may need to set @samp{TIME_STYLE="posix-long-iso"}. To avoid certain denial-of-service attacks, timestamps that would be @@ -7312,7 +7395,7 @@ Output strings as-is; this is the same as the @option{-N} or @item shell Quote strings for the shell if they contain shell metacharacters or would cause ambiguous output. -The quoting is suitable for @acronym{POSIX}-compatible shells like +The quoting is suitable for POSIX-compatible shells like @command{bash}, but it does not always work for incompatible shells like @command{csh}. @item shell-always @@ -7333,12 +7416,12 @@ locale. @c Use @t instead of @samp to avoid duplicate quoting in some output styles. Quote strings as for C character string literals, except use surrounding quotation marks appropriate for the locale, and quote -@t{`like this'} instead of @t{"like +@t{'like this'} instead of @t{"like this"} in the default C locale. This looks nicer on many displays. @end table You can specify the default value of the @option{--quoting-style} option -with the environment variable @env{QUOTING_STYLE}. If that environment +with the environment variable @env{QUOTING_STYLE}@. If that environment variable is not set, the default value is @samp{literal}, but this default may change to @samp{shell} in a future version of this package. @@ -7386,7 +7469,7 @@ terminal for color output from @command{ls} (and @command{dir}, etc.). Typical usage: @example -eval "`dircolors [@var{option}]@dots{} [@var{file}]`" +eval "$(dircolors [@var{option}]@dots{} [@var{file}])" @end example If @var{file} is specified, @command{dircolors} reads it to determine which @@ -7523,7 +7606,7 @@ link only when it refers to an existing regular file. However, when copying to a dangling symbolic link, @command{cp} refuses by default, and fails with a diagnostic, since the operation is inherently dangerous. This behavior is contrary to historical -practice and to @acronym{POSIX}. +practice and to POSIX@. Set @env{POSIXLY_CORRECT} to make @command{cp} attempt to create the target of a dangling destination symlink, in spite of the possible risk. Also, when an option like @@ -7559,11 +7642,11 @@ Try to preserve SELinux security context and extended attributes (xattr), but ignore any failure to do that and print no corresponding diagnostic. Equivalent to @option{-dR --preserve=all} with the reduced diagnostics. -@itemx --attributes-only +@item --attributes-only @opindex --attributes-only -Preserve the specified attributes of the original files in the copy, -but do not copy any data. See the @option{--preserve} option for -controlling which attributes to copy. +Copy only the specified attributes of the source file to the destination. +If the destination already exists, do not alter its contents. +See the @option{--preserve} option for controlling which attributes to copy. @item -b @itemx @w{@kbd{--backup}[=@var{method}]} @@ -7581,10 +7664,12 @@ combination of options is this tiny Bourne shell script: @example #!/bin/sh # Usage: backup FILE... -# Create a @sc{gnu}-style backup of each listed FILE. +# Create a GNU-style backup of each listed FILE. +fail=0 for i; do - cp --backup --force -- "$i" "$i" + cp --backup --force --preserve=all -- "$i" "$i" || fail=1 done +exit $fail @end example @item --copy-contents @@ -7617,7 +7702,7 @@ Equivalent to @option{--no-dereference --preserve=links}. @opindex -f @opindex --force When copying without this option and an existing destination file cannot -be opened for writing, the copy fails. However, with @option{--force}), +be opened for writing, the copy fails. However, with @option{--force}, when a destination file cannot be opened, @command{cp} then removes it and tries to open it again. Contrast this behavior with that enabled by @option{--link} and @option{--symbolic-link}, whereby the destination file @@ -7627,8 +7712,8 @@ description of @option{--remove-destination}. This option is independent of the @option{--interactive} or @option{-i} option: neither cancels the effect of the other. -This option is redundant if the @option{--no-clobber} or @option{-n} option is -used. +This option is ignored when the @option{--no-clobber} or @option{-n} option +is also used. @item -H @opindex -H @@ -7642,7 +7727,7 @@ via recursive traversal. @opindex -i @opindex --interactive When copying a file other than a directory, prompt whether to -overwrite an existing destination file. The @option{-i} option overrides +overwrite an existing destination file. The @option{-i} option overrides a previous @option{-n} option. @item -l @@ -7664,8 +7749,8 @@ a regular file in the destination tree. @itemx --no-clobber @opindex -n @opindex --no-clobber -Do not overwrite an existing file. The @option{-n} option overrides a previous -@option{-i} option. This option is mutually exclusive with @option{-b} or +Do not overwrite an existing file. The @option{-n} option overrides a previous +@option{-i} option. This option is mutually exclusive with @option{-b} or @option{--backup} option. @item -P @@ -7687,21 +7772,21 @@ If specified, the @var{attribute_list} must be a comma-separated list of one or more of the following strings: @table @samp -@itemx mode +@item mode Preserve the file mode bits and access control lists. -@itemx ownership +@item ownership Preserve the owner and group. On most modern systems, only users with appropriate privileges may change the owner of a file, and ordinary users may preserve the group ownership of a file only if they happen to be a member of the desired group. -@itemx timestamps +@item timestamps Preserve the times of last access and last modification, when possible. On older systems, it is not possible to preserve these attributes when the affected file is a symbolic link. However, many systems now provide the @code{utimensat} function, which makes it possible even for symbolic links. -@itemx links +@item links Preserve in the destination files any links between corresponding source files. Note that with @option{-L} or @option{-H}, this option can convert @@ -7725,14 +7810,15 @@ $ mkdir b c; (cd b; : > a; ln -s a b); cp -aL b c; ls -i1 c/b 74163295 b @end smallexample -@itemx context +@item context Preserve SELinux security context of the file, or fail with full diagnostics. -@itemx xattr +@item xattr Preserve extended attributes of the file, or fail with full diagnostics. If @command{cp} is built without xattr support, ignore this option. If SELinux context, ACLs or Capabilities are implemented using xattrs, -they are preserved by this option as well. -@itemx all +they are preserved implicitly by this option as well, i.e., even without +specifying @option{--preserve=mode} or @option{--preserve=context}. +@item all Preserve all file attributes. Equivalent to specifying all of the above, but with the difference that failure to preserve SELinux security context or extended attributes @@ -7748,12 +7834,12 @@ mode bits of the corresponding source file, minus the bits set in the umask and minus the set-user-ID and set-group-ID bits. @xref{File permissions}. -@itemx @w{@kbd{--no-preserve}=@var{attribute_list}} +@item @w{@kbd{--no-preserve}=@var{attribute_list}} @cindex file information, preserving Do not preserve the specified attributes. The @var{attribute_list} has the same form as for @option{--preserve}. -@itemx --parents +@item --parents @opindex --parents @cindex parent directories and @command{cp} Form the name of each destination file by appending to the target @@ -7786,10 +7872,10 @@ links in the source; see the @option{--archive} (@option{-a}), @option{-d}, creating a destination file of the same type as the source; see the @option{--copy-contents} option. It is not portable to use @option{-r} to copy symbolic links or special files. On some -non-@sc{gnu} systems, @option{-r} implies the equivalent of +non-GNU systems, @option{-r} implies the equivalent of @option{-L} and @option{--copy-contents} for historical reasons. Also, it is not portable to use @option{-R} to copy symbolic links -unless you also specify @option{-P}, as @acronym{POSIX} allows +unless you also specify @option{-P}, as POSIX allows implementations that dereference symbolic links by default. @item --reflink[=@var{when}] @@ -7798,7 +7884,7 @@ implementations that dereference symbolic links by default. @cindex clone @cindex copy on write Perform a lightweight, copy-on-write (COW) copy, if supported by the -file system. Once it has succeeded, beware that the source and destination +file system. Once it has succeeded, beware that the source and destination files share the same disk data blocks as long as they remain unmodified. Thus, if a disk I/O error affects data blocks of one of the files, the other suffers the same fate. @@ -7896,8 +7982,11 @@ same or newer modification time. If time stamps are being preserved, the comparison is to the source time stamp truncated to the resolutions of the destination file system and of the system calls used to update time stamps; this avoids duplicate work if several -@samp{cp -pu} commands are executed with the same source and -destination. +@samp{cp -pu} commands are executed with the same source and destination. +If @option{--preserve=links} is also specified (like with @samp{cp -au} +for example), that will take precedence. Consequently, depending on the +order that files are processed from the source, newer files in the destination +may be replaced, to mirror hard links in the source. @item -v @itemx --verbose @@ -7935,7 +8024,9 @@ dd @var{option} @end example The only options are @option{--help} and @option{--version}. -@xref{Common options}. @command{dd} accepts the following operands. +@xref{Common options}. @command{dd} accepts the following operands, +whose syntax was inspired by the DD (data definition) statement of +OS/360 JCL. @table @samp @@ -7986,23 +8077,49 @@ When converting variable-length records to fixed-length ones (@option{conv=block}) or the reverse (@option{conv=unblock}), use @var{bytes} as the fixed record length. -@item skip=@var{blocks} +@item skip=@var{n} @opindex skip -Skip @var{blocks} @samp{ibs}-byte blocks in the input file before copying. +Skip @var{n} @samp{ibs}-byte blocks in the input file before copying. +If @samp{iflag=skip_bytes} is specified, @var{n} is interpreted +as a byte count rather than a block count. -@item seek=@var{blocks} +@item seek=@var{n} @opindex seek -Skip @var{blocks} @samp{obs}-byte blocks in the output file before copying. +Skip @var{n} @samp{obs}-byte blocks in the output file before copying. +if @samp{oflag=seek_bytes} is specified, @var{n} is interpreted +as a byte count rather than a block count. -@item count=@var{blocks} +@item count=@var{n} @opindex count -Copy @var{blocks} @samp{ibs}-byte blocks from the input file, instead +Copy @var{n} @samp{ibs}-byte blocks from the input file, instead of everything until the end of the file. - -@item status=noxfer +if @samp{iflag=count_bytes} is specified, @var{n} is interpreted +as a byte count rather than a block count. +Note if the input may return short reads as could be the case +when reading from a pipe for example, @samp{iflag=fullblock} +will ensure that @samp{count=} corresponds to complete input blocks +rather than the traditional POSIX specified behavior of counting +input read operations. + +@item status=@var{which} @opindex status -Do not print the overall transfer rate and volume statistics -that normally make up the third status line when @command{dd} exits. +Transfer information is normally output to stderr upon +receipt of the @samp{INFO} signal or when @command{dd} exits. +Specifying @var{which} will identify which information to suppress. + +@table @samp + +@item noxfer +@opindex noxfer @r{dd status=} +Do not print the transfer rate and volume statistics +that normally make up the last status line. + +@item none +@opindex none @r{dd status=} +Do not print any informational messages to stderr. +Error messages are output as normal. + +@end table @item conv=@var{conversion}[,@var{conversion}]@dots{} @opindex conv @@ -8015,19 +8132,19 @@ Conversions: @item ascii @opindex ascii@r{, converting to} -Convert @acronym{EBCDIC} to @acronym{ASCII}, -using the conversion table specified by @acronym{POSIX}. +Convert EBCDIC to ASCII, +using the conversion table specified by POSIX@. This provides a 1:1 translation for all 256 bytes. @item ebcdic @opindex ebcdic@r{, converting to} -Convert @acronym{ASCII} to @acronym{EBCDIC}. +Convert ASCII to EBCDIC@. This is the inverse of the @samp{ascii} conversion. @item ibm @opindex alternate ebcdic@r{, converting to} -Convert @acronym{ASCII} to alternate @acronym{EBCDIC}, -using the alternate conversion table specified by @acronym{POSIX}. +Convert ASCII to alternate EBCDIC, +using the alternate conversion table specified by POSIX@. This is not a 1:1 translation, but reflects common historical practice for @samp{~}, @samp{[}, and @samp{]}. @@ -8056,23 +8173,37 @@ Change lowercase letters to uppercase. The @samp{lcase} and @samp{ucase} conversions are mutually exclusive. +@item sparse +@opindex sparse +Try to seek rather than write NUL output blocks. +On a file system that supports sparse files, this will create +sparse output when extending the output file. +Be careful when using this option in conjunction with +@samp{conv=notrunc} or @samp{oflag=append}. +With @samp{conv=notrunc}, existing data in the output file +corresponding to NUL blocks from the input, will be untouched. +With @samp{oflag=append} the seeks performed will be ineffective. +Similarly, when the output is a device rather than a file, +NUL input blocks are not copied, and therefore this option +is most useful with virtual or pre zeroed devices. + @item swab @opindex swab @r{(byte-swapping)} @cindex byte-swapping -Swap every pair of input bytes. @sc{gnu} @command{dd}, unlike others, works +Swap every pair of input bytes. GNU @command{dd}, unlike others, works when an odd number of bytes are read---the last byte is simply copied (since there is nothing to swap it with). @item sync -@opindex sync @r{(padding with @acronym{ASCII} @sc{nul}s)} +@opindex sync @r{(padding with ASCII NULs)} Pad every input block to size of @samp{ibs} with trailing zero bytes. When used with @samp{block} or @samp{unblock}, pad with spaces instead of zero bytes. @end table -The following ''conversions'' are really file flags -and don't effect and internal processing: +The following ``conversions'' are really file flags +and don't affect internal processing: @table @samp @item excl @@ -8141,7 +8272,7 @@ output file to be truncated before being appended to. @opindex cio @cindex concurrent I/O Use concurrent I/O mode for data. This mode performs direct I/O -and drops the @acronym{POSIX} requirement to serialize all I/O to the same file. +and drops the POSIX requirement to serialize all I/O to the same file. A file cannot be opened in CIO mode and with a standard open at the same time. @@ -8217,7 +8348,7 @@ idea to test it on your files before relying on it. @cindex controlling terminal Do not assign the file to be a controlling terminal for @command{dd}. This has no effect when the file is not a terminal. -On many hosts (e.g., @acronym{GNU}/Linux hosts), this option has no effect +On many hosts (e.g., GNU/Linux hosts), this option has no effect at all. @item nofollow @@ -8233,13 +8364,13 @@ Fail if the file has multiple hard links. @item binary @opindex binary @cindex binary I/O -Use binary I/O. This option has an effect only on nonstandard +Use binary I/O@. This option has an effect only on nonstandard platforms that distinguish binary from text I/O. @item text @opindex text @cindex text I/O -Use text I/O. Like @samp{binary}, this option has no effect on +Use text I/O@. Like @samp{binary}, this option has no effect on standard platforms. @item fullblock @@ -8249,6 +8380,31 @@ may return early if a full block is not available. When that happens, continue calling @code{read} to fill the remainder of the block. This flag can be used only with @code{iflag}. +This flag is useful with pipes for example +as they may return short reads. In that case, +this flag is needed to ensure that a @samp{count=} argument is +interpreted as a block count rather than a count of read operations. + +@item count_bytes +@opindex count_bytes +Interpret the @samp{count=} operand as a byte count, +rather than a block count, which allows specifying +a length that is not a multiple of the I/O block size. +This flag can be used only with @code{iflag}. + +@item skip_bytes +@opindex skip_bytes +Interpret the @samp{skip=} operand as a byte count, +rather than a block count, which allows specifying +an offset that is not a multiple of the I/O block size. +This flag can be used only with @code{iflag}. + +@item seek_bytes +@opindex seek_bytes +Interpret the @samp{seek=} operand as a byte count, +rather than a block count, which allows specifying +an offset that is not a multiple of the I/O block size. +This flag can be used only with @code{oflag}. @end table @@ -8262,8 +8418,8 @@ affected file descriptors, even after @command{dd} exits. @end table @cindex multipliers after numbers -The numeric-valued strings above (@var{bytes} and @var{blocks}) can be -followed by a multiplier: @samp{b}=512, @samp{c}=1, +The numeric-valued strings above (@var{n} and @var{bytes}) +can be followed by a multiplier: @samp{b}=512, @samp{c}=1, @samp{w}=2, @samp{x@var{m}}=@var{m}, or any of the standard block size suffixes like @samp{k}=1024 (@pxref{Block size}). @@ -8272,10 +8428,13 @@ should not be too large---values larger than a few megabytes are generally wasteful or (as in the gigabyte..exabyte case) downright counterproductive or error-inducing. -Use different @command{dd} invocations to use different block sizes for -skipping and I/O@. For example, the following shell commands copy data -in 512 KiB blocks between a disk and a tape, but do not save or restore a -4 KiB label at the start of the disk: +To process data that is at an offset or size that is not a +multiple of the I/O@ block size, you can use the @samp{skip_bytes}, +@samp{seek_bytes} and @samp{count_bytes} flags. Alternatively +the traditional method of separate @command{dd} invocations can be used. +For example, the following shell commands copy data +in 512 KiB blocks between a disk and a tape, but do not save +or restore a 4 KiB label at the start of the disk: @example disk=/dev/rdsk/c0t1d0s2 @@ -8464,7 +8623,7 @@ to when they were last installed. @cindex stripping symbol table information Strip the symbol tables from installed binary executables. -@itemx --strip-program=@var{program} +@item --strip-program=@var{program} @opindex --strip-program @cindex symbol table information, stripping, program Program used to strip binaries. @@ -8553,7 +8712,7 @@ when it might be a symlink to a directory. Otherwise, @command{mv} may do something very surprising, since its behavior depends on the underlying rename system call. On a system with a modern Linux-based kernel, it fails with -@code{errno=ENOTDIR}. +@code{errno=ENOTDIR}@. However, on other systems (at least FreeBSD 6.1 and Solaris 10) it silently renames not the symlink but rather the directory referenced by the symlink. @xref{Trailing slashes}. @@ -8664,11 +8823,18 @@ The program accepts the following options. Also see @ref{Common options}. @table @samp +@item -d +@itemx --dir +@opindex -d +@opindex --dir +@cindex directories, removing +Remove the listed directories if they are empty. + @item -f @itemx --force @opindex -f @opindex --force -Ignore nonexistent files and never prompt the user. +Ignore nonexistent files and missing operands, and never prompt the user. Ignore any previous @option{--interactive} (@option{-i}) option. @item -i @@ -8685,7 +8851,7 @@ files are named or if a recursive removal is requested. Ignore any previous @option{--force} (@option{-f}) option. Equivalent to @option{--interactive=once}. -@itemx --interactive [=@var{when}] +@item --interactive [=@var{when}] @opindex --interactive Specify when to issue an interactive prompt. @var{when} may be omitted, or one of: @@ -8704,7 +8870,7 @@ removal is requested. Equivalent to @option{-I}. @option{--interactive} with no @var{when} is equivalent to @option{--interactive=always}. -@itemx --one-file-system +@item --one-file-system @opindex --one-file-system @cindex one file system, restricting @command{rm} to When removing a hierarchy recursively, skip any directory that is on a @@ -8723,7 +8889,7 @@ warn about and skip directories on other file systems. Of course, this will not save your @file{/home} if it and your chroot happen to be on the same file system. -@itemx --preserve-root +@item --preserve-root @opindex --preserve-root @cindex root directory, disallow recursive destruction Fail upon any attempt to remove the root directory, @file{/}, @@ -8731,7 +8897,7 @@ when used with the @option{--recursive} option. This is the default behavior. @xref{Treating / specially}. -@itemx --no-preserve-root +@item --no-preserve-root @opindex --no-preserve-root @cindex root directory, allow recursive destruction Do not treat @file{/} specially when removing recursively. @@ -8759,7 +8925,7 @@ Print the name of each file before removing it. @cindex files beginning with @samp{-}, removing @cindex @samp{-}, removing files beginning with One common question is how to remove files whose names begin with a -@samp{-}. @sc{gnu} @command{rm}, like every program that uses the @code{getopt} +@samp{-}. GNU @command{rm}, like every program that uses the @code{getopt} function to parse its arguments, lets you use the @samp{--} option to indicate that all following arguments are non-options. To remove a file called @file{-f} in the current directory, you could type either: @@ -8821,7 +8987,7 @@ floppies, the patterns are designed for best effect on hard drives. For more details, see the source code and Peter Gutmann's paper @uref{http://www.cs.auckland.ac.nz/~pgut001/pubs/secure_del.html, @cite{Secure Deletion of Data from Magnetic and Solid-State Memory}}, -from the proceedings of the Sixth @acronym{USENIX} Security Symposium (San Jose, +from the proceedings of the Sixth USENIX Security Symposium (San Jose, California, July 22--25, 1996). @strong{Please note} that @command{shred} relies on a very important assumption: @@ -8834,7 +9000,7 @@ assumption. Exceptions include: @item Log-structured or journaled file systems, such as those supplied with AIX and Solaris, and JFS, ReiserFS, XFS, Ext3 (in @code{data=journal} mode), -BFS, NTFS, etc.@: when they are configured to journal @emph{data}. +BFS, NTFS, etc., when they are configured to journal @emph{data}. @item File systems that write redundant data and carry on even if some writes @@ -8853,7 +9019,7 @@ Compressed file systems. In the particular case of ext3 file systems, the above disclaimer applies (and @command{shred} is thus of limited effectiveness) only in @code{data=journal} -mode, which journals file data in addition to just metadata. In both +mode, which journals file data in addition to just metadata. In both the @code{data=ordered} (default) and @code{data=writeback} modes, @command{shred} works as usual. Ext3 journaling modes can be changed by adding the @code{data=something} option to the mount options for a @@ -8906,8 +9072,8 @@ Override file permissions if necessary to allow overwriting. @opindex --iterations=@var{number} @cindex iterations, selecting the number of By default, @command{shred} uses @value{SHRED_DEFAULT_PASSES} passes of -overwrite. You can reduce this to save time, or increase it if you think it's -appropriate. After 25 passes all of the internal overwrite patterns will have +overwrite. You can reduce this to save time, or increase it if you think it's +appropriate. After 25 passes all of the internal overwrite patterns will have been used at least once. @item --random-source=@var{file} @@ -8999,7 +9165,7 @@ The intended use of this is to shred a removed temporary file. For example: @example -i=`mktemp` +i=$(mktemp) exec 3<>"$i" rm -- "$i" echo "Hello, world" >&3 @@ -9075,10 +9241,10 @@ must specify a nonexistent entry in an existing directory. @command{link} simply calls @code{link (@var{filename}, @var{linkname})} to create the link. -On a @acronym{GNU} system, this command acts like @samp{ln --directory +On a GNU system, this command acts like @samp{ln --directory --no-target-directory @var{filename} @var{linkname}}. However, the @option{--directory} and @option{--no-target-directory} options are -not specified by @acronym{POSIX}, and the @command{link} command is +not specified by POSIX, and the @command{link} command is more portable in practice. If @var{filename} is a symbolic link, it is unspecified whether @@ -9145,7 +9311,7 @@ file. Most systems prohibit making a hard link to a directory; on those where it is allowed, only the super-user can do so (and with caution, since creating a cycle will cause problems to many other utilities). Hard links cannot cross file system boundaries. (These -restrictions are not mandated by @acronym{POSIX}, however.) +restrictions are not mandated by POSIX, however.) @cindex dereferencing symbolic links @cindex symbolic link, defined @@ -9257,6 +9423,22 @@ symbolic link with identical contents; since symbolic link contents cannot be edited, any file name resolution performed through either link will be the same as if a hard link had been created. +@item -r +@itemx --relative +@opindex -r +@opindex --relative +Make symbolic links relative to the link location. + +Example: + +@smallexample +ln -srv /a/file /tmp +'/tmp/file' -> '../a/file' +@end smallexample + +@xref{realpath invocation}, which gives greater control +over relative file name generation. + @item -s @itemx --symbolic @opindex -s @@ -9350,7 +9532,7 @@ in @command{chmod} and uses @samp{a=rwx} (read, write and execute allowed for everyone) for the point of the departure. @xref{File permissions}. Normally the directory has the desired file mode bits at the moment it -is created. As a @acronym{GNU} extension, @var{mode} may also mention +is created. As a GNU extension, @var{mode} may also mention special mode bits, but in this case there may be a temporary window during which the directory exists but its special mode bits are incorrect. @xref{Directory Setuid and Setgid}, for how the @@ -9486,7 +9668,7 @@ for a FIFO for a block special file @item c -@c Don't document the `u' option -- it's just a synonym for `c'. +@c Don't document the 'u' option -- it's just a synonym for 'c'. @c Do *any* versions of mknod still use it? @c @itemx u @opindex c @r{for character special file} @@ -9534,7 +9716,6 @@ Set the default SELinux security context to be used for created files. @cindex displaying value of a symbolic link @cindex canonical file name @cindex canonicalize a file name -@pindex realpath @findex realpath @command{readlink} may work in one of two supported modes: @@ -9543,20 +9724,20 @@ Set the default SELinux security context to be used for created files. @item Readlink mode -@command{readlink} outputs the value of the given symbolic link. +@command{readlink} outputs the value of the given symbolic links. If @command{readlink} is invoked with an argument other than the name of a symbolic link, it produces no output and exits with a nonzero exit code. @item Canonicalize mode -@command{readlink} outputs the absolute name of the given file which contains +@command{readlink} outputs the absolute name of the given files which contain no @file{.}, @file{..} components nor any repeated separators (@file{/}) or symbolic links. @end table @example -readlink [@var{option}] @var{file} +readlink [@var{option}]@dots{} @var{file}@dots{} @end example By default, @command{readlink} operates in readlink mode. @@ -9595,7 +9776,8 @@ as a directory. @itemx --no-newline @opindex -n @opindex --no-newline -Do not output the trailing newline. +Do not print the output delimiter, when a single @var{file} is specified. +Print a warning if specified along with multiple @var{file}s. @item -s @itemx -q @@ -9613,12 +9795,18 @@ Suppress most error messages. @opindex --verbose Report error messages. +@item -z +@itemx --zero +@opindex -z +@opindex --zero +Separate output items with NUL characters. + @end table The @command{readlink} utility first appeared in OpenBSD 2.1. -There is a @command{realpath} command on some systems -which operates like @command{readlink} in canonicalize mode. +The @command{realpath} command without options, operates like +@command{readlink} in canonicalize mode. @exitstatus @@ -9721,9 +9909,9 @@ timestamps, and other information. Collectively, we call these a file's These commands change file attributes. @menu +* chown invocation:: Change file owners and groups. * chgrp invocation:: Change file groups. * chmod invocation:: Change access permissions. -* chown invocation:: Change file owners and groups. * touch invocation:: Change file timestamps. @end menu @@ -9787,8 +9975,8 @@ or group ID, then you may specify it with a leading @samp{+}. @xref{Disambiguating names and IDs}. Some older scripts may still use @samp{.} in place of the @samp{:} separator. -@acronym{POSIX} 1003.1-2001 (@pxref{Standards conformance}) does not -require support for that, but for backward compatibility @acronym{GNU} +POSIX 1003.1-2001 (@pxref{Standards conformance}) does not +require support for that, but for backward compatibility GNU @command{chown} supports @samp{.} so long as no ambiguity results. New scripts should avoid the use of @samp{.} because it is not portable, and because it has undesirable results if the entire @@ -9828,7 +10016,7 @@ actually changes. Do not print error messages about files whose ownership cannot be changed. -@itemx @w{@kbd{--from}=@var{old-owner}} +@item @w{@kbd{--from}=@var{old-owner}} @opindex --from @cindex symbolic links, changing owner Change a @var{file}'s ownership only if it has current attributes specified @@ -9882,14 +10070,14 @@ is a symbolic link. By default, no diagnostic is issued for symbolic links encountered during a recursive traversal, but see @option{--verbose}. -@itemx --preserve-root +@item --preserve-root @opindex --preserve-root @cindex root directory, disallow recursive modification Fail upon any attempt to recursively change the root directory, @file{/}. Without @option{--recursive}, this option has no effect. @xref{Treating / specially}. -@itemx --no-preserve-root +@item --no-preserve-root @opindex --no-preserve-root @cindex root directory, allow recursive modification Cancel the effect of any preceding @option{--preserve-root} option. @@ -10009,14 +10197,14 @@ is a symbolic link. By default, no diagnostic is issued for symbolic links encountered during a recursive traversal, but see @option{--verbose}. -@itemx --preserve-root +@item --preserve-root @opindex --preserve-root @cindex root directory, disallow recursive modification Fail upon any attempt to recursively change the root directory, @file{/}. Without @option{--recursive}, this option has no effect. @xref{Treating / specially}. -@itemx --no-preserve-root +@item --no-preserve-root @opindex --no-preserve-root @cindex root directory, allow recursive modification Cancel the effect of any preceding @option{--preserve-root} option. @@ -10131,14 +10319,14 @@ actually changes. Do not print error messages about files whose permissions cannot be changed. -@itemx --preserve-root +@item --preserve-root @opindex --preserve-root @cindex root directory, disallow recursive modification Fail upon any attempt to recursively change the root directory, @file{/}. Without @option{--recursive}, this option has no effect. @xref{Treating / specially}. -@itemx --no-preserve-root +@item --no-preserve-root @opindex --no-preserve-root @cindex root directory, allow recursive modification Cancel the effect of any preceding @option{--preserve-root} option. @@ -10193,11 +10381,39 @@ A @var{file} argument string of @samp{-} is handled specially and causes @command{touch} to change the times of the file associated with standard output. +@cindex clock skew +By default, @command{touch} sets file timestamps to the current time. +Because @command{touch} acts on its operands left to right, the +resulting timestamps of earlier and later operands may disagree. +Also, the determination of what time is ``current'' depends on the +platform. Platforms with network file systems often use different +clocks for the operating system and for file systems; because +@command{touch} typically uses file systems' clocks by default, clock +skew can cause the resulting file timestamps to appear to be in a +program's ``future'' or ``past''. + +@cindex file timestamp resolution +The @command{touch} command sets the file's timestamp to the greatest +representable value that is not greater than the requested time. This +can differ from the requested time for several reasons. First, the +requested time may have a higher resolution than supported. Second, a +file system may use different resolutions for different types of +times. Third, file timestamps may use a different resolution than +operating system timestamps. Fourth, the operating system primitives +used to update timestamps may employ yet a different resolution. For +example, in theory a file system might use 10-microsecond resolution +for access time and 100-nanosecond resolution for modification time, +and the operating system might use nanosecond resolution for the +current time and microsecond resolution for the primitive that +@command{touch} uses to set a file's timestamp to an arbitrary value. + @cindex permissions, for changing file timestamps -If changing both the access and modification times to the current -time, @command{touch} can change the timestamps for files that the user -running it does not own but has write permission for. Otherwise, the -user must own the files. +When setting file timestamps to the current time, @command{touch} can +change the timestamps for files that the user does not own but has +write permission for. Otherwise, the user must own the files. Some +older systems have a further restriction: the user must own the files +unless both the access and modification times are being set to the +current time. Although @command{touch} provides options for changing two of the times---the times of last access and modification---of a file, there is actually @@ -10224,7 +10440,7 @@ environment variable, or by the system default rules if @env{TZ} is not set. @xref{TZ Variable,, Specifying the Time Zone with @env{TZ}, libc, The GNU C Library Reference Manual}. You can avoid ambiguities during -daylight saving transitions by using @sc{utc} time stamps. +daylight saving transitions by using UTC time stamps. The program accepts the following options. Also see @ref{Common options}. @@ -10257,7 +10473,7 @@ time zones, @samp{am} and @samp{pm}, @samp{yesterday}, etc. For example, @option{--date="2004-02-27 14:19:13.489392193 +0530"} specifies the instant of time that is 489,392,193 nanoseconds after February 27, 2004 at 2:19:13 PM in a time zone that is 5 hours and 30 -minutes east of @acronym{UTC}. @xref{Date input formats}. +minutes east of UTC@. @xref{Date input formats}. File systems that do not support high-resolution time stamps silently ignore any excess precision here. @@ -10277,7 +10493,7 @@ the link refers to. When using this option, empty files are not created, but option @option{-c} must also be used to avoid warning about files that do not exist. Not all systems support changing the timestamps of symlinks, since underlying system support for this -action was not required until @acronym{POSIX} 2008. Also, on some +action was not required until POSIX 2008. Also, on some systems, the mere act of examining a symbolic link changes the access time, such that only changes to the modification time will persist long enough to be observable. When coupled with option @option{-r}, a @@ -10307,13 +10523,15 @@ If @var{file} is a symbolic link, the reference timestamp is taken from the target of the symlink, unless @option{-h} was also in effect. @item -t [[@var{cc}]@var{yy}]@var{mmddhhmm}[.@var{ss}] +@cindex leap seconds Use the argument (optional four-digit or two-digit years, months, days, hours, minutes, optional seconds) instead of the current time. If the year is specified with only two digits, then @var{cc} is 20 for years in the range 0 @dots{} 68, and 19 for years in 69 @dots{} 99. If no digits of the year are specified, the argument is interpreted as a date in the current year. -Note that @var{ss} may be @samp{60}, to accommodate leap seconds. +On the atypical systems that support leap seconds, @var{ss} may be +@samp{60}. @end table @@ -10376,12 +10594,22 @@ Normally the disk space is printed in units of 1024 bytes, but this can be overridden (@pxref{Block size}). Non-integer quantities are rounded up to the next higher unit. +For bind mounts and without arguments, @command{df} only outputs the statistics +for that device with the shortest mount point name in the list of file systems +(@var{mtab}), i.e., it hides duplicate entries, unless the @option{-a} option is +specified. + +With the same logic, @command{df} elides a mount entry of a dummy pseude device +if there is another mount entry of a real block device for that mount point with +the same device number, e.g. the early-boot pseudo file system @samp{rootfs} is +not shown per default when already the real root device has been mounted. + @cindex disk device file @cindex device file, disk If an argument @var{file} is a disk device file containing a mounted file system, @command{df} shows the space available on that file system rather than on the file system containing the device node (i.e., the root -file system). @sc{gnu} @command{df} does not attempt to determine the +file system). GNU @command{df} does not attempt to determine the disk usage on unmounted file systems, because on most kinds of systems doing so requires extremely nonportable intimate knowledge of file system @@ -10409,13 +10637,19 @@ pseudo-file-systems, such as automounter entries. Scale sizes by @var{size} before printing them (@pxref{Block size}). For example, @option{-BG} prints sizes in units of 1,073,741,824 bytes. -@itemx --total +@item --total @opindex --total @cindex grand total of disk size, usage and available space Print a grand total of all arguments after all arguments have been processed. This can be used to find out the total disk size, usage and available space of all listed devices. +For the grand total line, @command{df} prints @samp{"total"} into the +@var{source} column, and @samp{"-"} into the @var{target} column. +If there is no @var{source} column (see @option{--output}), then +@command{df} prints @samp{"total"} into the @var{target} column, +if present. + @optHumanReadable @item -H @@ -10454,15 +10688,76 @@ This may make @command{df} run significantly faster on systems with many disks, but on some systems (notably SunOS) the results may be slightly out of date. This is the default. +@item --output +@itemx @w{@kbd{--output}[=@var{field_list}]} +@opindex --output +Use the output format defined by @var{field_list}, or print all fields if +@var{field_list} is omitted. In the latter case, the order of the columns +conforms to the order of the field descriptions below. + +The use of the @option{--output} together with each of the options @option{-i}, +@option{-P}, and @option{-T} is mutually exclusive. + +FIELD_LIST is a comma-separated list of columns to be included in @command{df}'s +output and therefore effectively controls the order of output columns. +Each field can thus be used at the place of choice, but yet must only be +used once. + +Valid field names in the @var{field_list} are: +@table @samp +@item source +The source of the mount point, usually a device. +@item fstype +File system type. + +@item itotal +Total number of inodes. +@item iused +Number of used inodes. +@item iavail +Number of available inodes. +@item ipcent +Percentage of @var{iused} divided by @var{itotal}. + +@item size +Total number of blocks. +@item used +Number of used blocks. +@item avail +Number of available blocks. +@item pcent +Percentage of @var{used} divided by @var{size}. + +@item target +The mount point. +@end table + +The fields for block and inodes statistics are affected by the scaling +options like @option{-h} as usual. + +The definition of the @var{field_list} can even be splitted among several +@option{--output} uses. + +@example +#!/bin/sh +# Print the TARGET (i.e., the mount point) along with their percentage +# statistic regarding the blocks and the inodes. +df --out=target --output=pcent,ipcent + +# Print all available fields. +df --o +@end example + + @item -P @itemx --portability @opindex -P @opindex --portability @cindex one-line output format -@cindex @acronym{POSIX} output format +@cindex POSIX output format @cindex portable output format @cindex output format, portable -Use the @acronym{POSIX} output format. This is like the default format except +Use the POSIX output format. This is like the default format except for the following: @enumerate @@ -10473,7 +10768,7 @@ that if the mount device name is more than 20 characters long (e.g., for some network mounts), the columns are misaligned. @item -The labels in the header output line are changed to conform to @acronym{POSIX}. +The labels in the header output line are changed to conform to POSIX. @item The default block size and output format are unaffected by the @@ -10515,8 +10810,8 @@ the common names (this list is certainly not exhaustive): @table @samp @item nfs -@cindex @acronym{NFS} file system type -An @acronym{NFS} file system, i.e., one mounted over a network from another +@cindex NFS file system type +An NFS file system, i.e., one mounted over a network from another machine. This is the one type name which seems to be used uniformly by all systems. @@ -10566,6 +10861,11 @@ inspect the exit status of a command like @samp{df -t ext3 -t reiserfs @var{dir}} to test whether @var{dir} is on a file system of type @samp{ext3} or @samp{reiserfs}. +Since the list of file systems (@var{mtab}) is needed to determine the +file system type, failure includes the cases when that list cannot +be read and one or more of the options @option{-a}, @option{-l}, @option{-t} +or @option{-x} is used together with a file name argument. + @node du invocation @section @command{du}: Estimate file space usage @@ -10595,13 +10895,15 @@ The program accepts the following options. Also see @ref{Common options}. @table @samp +@optNull{du} + @item -a @itemx --all @opindex -a @opindex --all Show counts for all files, not just directories. -@itemx --apparent-size +@item --apparent-size @opindex --apparent-size Print apparent sizes, rather than disk usage. The apparent size of a file is the number of bytes reported by @code{wc -c} on regular files, @@ -10620,12 +10922,6 @@ dd bs=1 seek=2GiB if=/dev/null of=big has an apparent size of 2 GiB, yet on most modern systems, it actually uses almost no disk space. -@item -b -@itemx --bytes -@opindex -b -@opindex --bytes -Equivalent to @code{--apparent-size --block-size=1}. - @item -B @var{size} @itemx --block-size=@var{size} @opindex -B @@ -10634,6 +10930,12 @@ Equivalent to @code{--apparent-size --block-size=1}. Scale sizes by @var{size} before printing them (@pxref{Block size}). For example, @option{-BG} prints sizes in units of 1,073,741,824 bytes. +@item -b +@itemx --bytes +@opindex -b +@opindex --bytes +Equivalent to @code{--apparent-size --block-size=1}. + @item -c @itemx --total @opindex -c @@ -10652,15 +10954,24 @@ Does not affect other symbolic links. This is helpful for finding out the disk usage of directories, such as @file{/usr/tmp}, which are often symbolic links. +@item -d @var{depth} +@itemx --max-depth=@var{depth} +@opindex -d @var{depth} +@opindex --max-depth=@var{depth} +@cindex limiting output of @command{du} +Show the total for each directory (and file if --all) that is at +most MAX_DEPTH levels down from the root of the hierarchy. The root +is at level 0, so @code{du --max-depth=0} is equivalent to @code{du -s}. + @c --files0-from=FILE @filesZeroFromOption{du,, with the @option{--total} (@option{-c}) option} -@optHumanReadable - @item -H @opindex -H Equivalent to @option{--dereference-args} (@option{-D}). +@optHumanReadable + @item -k @opindex -k @cindex kibibytes for file sizes @@ -10668,14 +10979,6 @@ Print sizes in 1024-byte blocks, overriding the default block size (@pxref{Block size}). This option is equivalent to @option{--block-size=1K}. -@item -l -@itemx --count-links -@opindex -l -@opindex --count-links -@cindex hard links, counting in @command{du} -Count the size of all files, even if they have appeared already (as a -hard link). - @item -L @itemx --dereference @opindex -L @@ -10685,6 +10988,14 @@ Dereference symbolic links (show the disk space used by the file or directory that the link points to instead of the space used by the link). +@item -l +@itemx --count-links +@opindex -l +@opindex --count-links +@cindex hard links, counting in @command{du} +Count the size of all files, even if they have appeared already (as a +hard link). + @item -m @opindex -m @cindex mebibytes for file sizes @@ -10700,25 +11011,6 @@ This option is equivalent to @option{--block-size=1M}. For each symbolic links encountered by @command{du}, consider the disk space used by the symbolic link. -@item -d @var{depth} -@item --max-depth=@var{depth} -@opindex -d @var{depth} -@opindex --max-depth=@var{depth} -@cindex limiting output of @command{du} -Show the total for each directory (and file if --all) that is at -most MAX_DEPTH levels down from the root of the hierarchy. The root -is at level 0, so @code{du --max-depth=0} is equivalent to @code{du -s}. - -@optNull{du} - -@optSi - -@item -s -@itemx --summarize -@opindex -s -@opindex --summarize -Display only a total for each argument. - @item -S @itemx --separate-dirs @opindex -S @@ -10730,13 +11022,56 @@ With @option{--separate-dirs}, the size reported for a directory name, @var{d}, is merely the @code{stat.st_size}-derived size of the directory entry, @var{d}. -@itemx --time +@optSi + +@item -s +@itemx --summarize +@opindex -s +@opindex --summarize +Display only a total for each argument. + +@item -t @var{size} +@itemx --threshold=@var{size} +@opindex -t +@opindex --threshold +Exclude entries based on a given @var{size} (@pxref{Block size}). + +If @var{size} is positive, then @command{du} will only print entries with a size +greater than or equal to that. + +If @var{size} is negative, then @command{du} will only print entries with a size +smaller than or equal to that. + +Although GNU @command{find} can be used to find files of a certain size, +@command{du}'s @option{--threshold} option can be used to also filter +directories based on a given size. + +Please note that the @option{--threshold} option can be combined with the +@option{--apparent-size} option, and in this case would elide entries based on +its apparent size. + +Here's how you would use @option{--threshold} to find directories with a size +greater than or equal to 200 megabytes: + +@example +du --threshold=200MB +@end example + +Here's how you would use @option{--threshold} to find directories and files - +note the @option{-a} - with an apparent size smaller than or equal to 500 bytes: + +@example +du -a -t -500 --apparent-size +@end example + + +@item --time @opindex --time @cindex last modified dates, displaying in @command{du} Show time of the most recent modification of any file in the directory, or any of its subdirectories. -@itemx --time=ctime +@item --time=ctime @itemx --time=status @itemx --time=use @opindex --time @@ -10746,7 +11081,7 @@ or any of its subdirectories. Show the most recent status change time (the @samp{ctime} in the inode) of any file in the directory, instead of the modification time. -@itemx --time=atime +@item --time=atime @itemx --time=access @opindex --time @opindex atime@r{, show the most recent} @@ -10772,19 +11107,19 @@ with @command{date}, @var{format}'s interpretation is affected by the @env{LC_TIME} locale category. @item full-iso -List timestamps in full using @acronym{ISO} 8601 date, time, and time zone +List timestamps in full using ISO 8601 date, time, and time zone format with nanosecond precision, e.g., @samp{2002-03-30 23:45:56.477817180 -0700}. This style is equivalent to @samp{+%Y-%m-%d %H:%M:%S.%N %z}. @item long-iso -List @acronym{ISO} 8601 date and time in minutes, e.g., +List ISO 8601 date and time in minutes, e.g., @samp{2002-03-30 23:45}. These timestamps are shorter than @samp{full-iso} timestamps, and are usually good enough for everyday work. This style is equivalent to @samp{+%Y-%m-%d %H:%M}. @item iso -List @acronym{ISO} 8601 dates for timestamps, e.g., @samp{2002-03-30}. +List ISO 8601 dates for timestamps, e.g., @samp{2002-03-30}. This style is equivalent to @samp{+%Y-%m-%d}. @end table @@ -10797,21 +11132,6 @@ the newline and any later characters are ignored; if @env{TIME_STYLE} begins with @samp{posix-} the @samp{posix-} is ignored; and if @env{TIME_STYLE} is @samp{locale} it is ignored. -@item -x -@itemx --one-file-system -@opindex -x -@opindex --one-file-system -@cindex one file system, restricting @command{du} to -Skip directories that are on different file systems from the one that -the argument being processed is on. - -@item --exclude=@var{pattern} -@opindex --exclude=@var{pattern} -@cindex excluding files from @command{du} -When recursing, skip subdirectories or files matching @var{pattern}. -For example, @code{du --exclude='*.o'} excludes files whose names -end in @samp{.o}. - @item -X @var{file} @itemx --exclude-from=@var{file} @opindex -X @var{file} @@ -10821,6 +11141,21 @@ Like @option{--exclude}, except take the patterns to exclude from @var{file}, one per line. If @var{file} is @samp{-}, take the patterns from standard input. +@item --exclude=@var{pattern} +@opindex --exclude=@var{pattern} +@cindex excluding files from @command{du} +When recursing, skip subdirectories or files matching @var{pattern}. +For example, @code{du --exclude='*.o'} excludes files whose names +end in @samp{.o}. + +@item -x +@itemx --one-file-system +@opindex -x +@opindex --one-file-system +@cindex one file system, restricting @command{du} to +Skip directories that are on different file systems from the one that +the argument being processed is on. + @end table @cindex NFS mounts from BSD to HP-UX @@ -10889,7 +11224,7 @@ $ stat --format=%d:%i / /usr 2057:2 @end example -@itemx --printf=@var{format} +@item --printf=@var{format} @opindex --printf=@var{format} @cindex output format Use @var{format} rather than the default format. @@ -10933,7 +11268,7 @@ The valid @var{format} directives for files with @option{--format} and @item %m - Mount point (See note below) @item %n - File name @item %N - Quoted file name with dereference if symbolic link -@item %o - I/O block size +@item %o - Optimal I/O transfer size hint @item %s - Total size, in bytes @item %t - Major device type in hex @item %T - Minor device type in hex @@ -10954,7 +11289,7 @@ precision preceded by a period to specify the number of digits to print after the decimal point. For example, @samp{%.3X} outputs the last access time to millisecond precision. If a period is given but no precision, @command{stat} uses 9 digits, so @samp{%.X} is equivalent to -@samp{%.9X}. When discarding excess precision, time stamps are truncated +@samp{%.9X}@. When discarding excess precision, time stamps are truncated toward minus infinity. @example @@ -11051,7 +11386,7 @@ Any arguments are ignored, except for a lone @option{--help} or @cindex truncating, file sizes @command{truncate} shrinks or extends the size of each @var{file} to the -specified size. Synopsis: +specified size. Synopsis: @example truncate @var{option}@dots{} @var{file}@dots{} @@ -11210,7 +11545,7 @@ option-like arguments instead of treating them as options. For example, @code{echo -ne hello} outputs @samp{-ne hello} instead of plain @samp{hello}. -@acronym{POSIX} does not require support for any options, and says +POSIX does not require support for any options, and says that the behavior of @command{echo} is implementation-defined if any @var{string} contains a backslash or if the first argument is @option{-n}. Portable programs can use the @command{printf} command @@ -11286,8 +11621,8 @@ then its value is the numeric value of the immediately following character. Any remaining characters are silently ignored if the @env{POSIXLY_CORRECT} environment variable is set; otherwise, a warning is printed. For example, @samp{printf "%d" "'a"} outputs -@samp{97} on hosts that use the @acronym{ASCII} character set, since -@samp{a} has the numeric value 97 in @acronym{ASCII}. +@samp{97} on hosts that use the ASCII character set, since +@samp{a} has the numeric value 97 in ASCII. @end itemize @@ -11315,15 +11650,15 @@ For example, @samp{printf '\400'} is equivalent to @samp{printf '\0'}. @cindex ISO/IEC 10646 @vindex LC_CTYPE @command{printf} interprets two character syntaxes introduced in -@acronym{ISO} C 99: -@samp{\u} for 16-bit Unicode (@acronym{ISO}/@acronym{IEC} 10646) +ISO C 99: +@samp{\u} for 16-bit Unicode (ISO/IEC 10646) characters, specified as four hexadecimal digits @var{hhhh}, and @samp{\U} for 32-bit Unicode characters, specified as eight hexadecimal digits @var{hhhhhhhh}. @command{printf} outputs the Unicode characters according to the @env{LC_CTYPE} locale. Unicode characters in the ranges -U+0000...U+009F, U+D800...U+DFFF cannot be specified by this syntax, except -for U+0024 ($), U+0040 (@@), and U+0060 (@`). +U+0000@dots{}U+009F, U+D800@dots{}U+DFFF cannot be specified by this syntax, +except for U+0024 ($), U+0040 (@@), and U+0060 (@`). The processing of @samp{\u} and @samp{\U} requires a full-featured @code{iconv} facility. It is activated on systems with glibc 2.2 (or newer), @@ -11343,7 +11678,7 @@ $ env printf '\u20AC 14.95' @noindent will be output correctly in all locales supporting the Euro symbol -(@acronym{ISO}-8859-15, UTF-8, and others). Similarly, a Chinese string +(ISO-8859-15, UTF-8, and others). Similarly, a Chinese string @example $ env printf '\u4e2d\u6587' @@ -11357,7 +11692,7 @@ invoked via @command{env} to ensure that we run the program found via your shell's search path, and not a shell alias or a built-in function. For larger strings, you don't need to look up the hexadecimal code -values of each character one by one. @acronym{ASCII} characters mixed with \u +values of each character one by one. ASCII characters mixed with \u escape sequences is also known as the JAVA source file encoding. You can use GNU recode 3.5c (or newer) to convert strings to this encoding. Here is how to convert a piece of text into a shell script which will output @@ -11439,7 +11774,7 @@ exits unsuccessfully, even when invoked with Portable programs should not assume that the exit status of @command{false} is 1, as it is greater than 1 on some -non-@acronym{GNU} hosts. +non-GNU hosts. @node true invocation @@ -11833,7 +12168,7 @@ e.g., spaces. However, regardless of whether it is quoted, a string operand should not be a parenthesis or any of @command{expr}'s operators like @code{+}, so you cannot safely pass an arbitrary string @code{$str} to expr merely by quoting it to the shell. One way to -work around this is to use the @sc{gnu} extension @code{+}, +work around this is to use the GNU extension @code{+}, (e.g., @code{+ "$str" = foo}); a more portable way is to use @code{@w{" $str"}} and to adjust the rest of the expression to take the leading space into account (e.g., @code{@w{" $str" = " foo"}}). @@ -11915,7 +12250,7 @@ expression operators. In the regular expression, @code{\+}, @code{\?}, and @code{\|} are operators which respectively match one or more, zero or one, or separate alternatives. SunOS and other @command{expr}'s treat these as regular -characters. (@acronym{POSIX} allows either behavior.) +characters. (POSIX allows either behavior.) @xref{Top, , Regular Expression Library, regex, Regex}, for details of regular expression syntax. Some examples are in @ref{Examples of expr}. @@ -11947,7 +12282,7 @@ or an operator like @code{/}. This makes it possible to test @code{expr length + "$x"} or @code{expr + "$x" : '.*/\(.\)'} and have it do the right thing even if the value of @var{$x} happens to be (for example) @code{/} or @code{index}. -This operator is a @acronym{GNU} extension. Portable shell scripts should use +This operator is a GNU extension. Portable shell scripts should use @code{@w{" $token"} : @w{' \(.*\)'}} instead of @code{+ "$token"}. @end table @@ -12047,7 +12382,7 @@ Here are a few examples, including quoting for shell metacharacters. To add 1 to the shell variable @code{foo}, in Bourne-compatible shells: @example -foo=`expr $foo + 1` +foo=$(expr $foo + 1) @end example To print the non-directory part of the file name stored in @@ -12166,7 +12501,7 @@ checksum in a file named @file{dvd.sha1}. Note, however, that this example relies on a feature of modern shells called @dfn{process substitution} (the @samp{>(command)} syntax, above; -@xref{Process Substitution,,Process Substitution, bashref, +@xref{Process Substitution,,Process Substitution, bash, The Bash Reference Manual}.), so it works with @command{zsh}, @command{bash}, and @command{ksh}, but not with @command{/bin/sh}. So if you write code like this @@ -12257,6 +12592,7 @@ This section describes commands that manipulate file names. * dirname invocation:: Strip last file name component. * pathchk invocation:: Check file name validity and portability. * mktemp invocation:: Create temporary file or directory. +* realpath invocation:: Print resolved file names. @end menu @@ -12275,6 +12611,7 @@ This section describes commands that manipulate file names. @example basename @var{name} [@var{suffix}] +basename @var{option}@dots{} @var{name}@dots{} @end example If @var{suffix} is specified and is identical to the end of @var{name}, @@ -12292,14 +12629,39 @@ for everything except file names containing a trailing newline. @end macro @basenameAndDirname -@acronym{POSIX} allows the implementation to define the results if -@var{name} is empty or @samp{//}. In the former case, @acronym{GNU} +POSIX allows the implementation to define the results if +@var{name} is empty or @samp{//}. In the former case, GNU @command{basename} returns the empty string. In the latter case, the result is @samp{//} on platforms where @var{//} is distinct from @var{/}, and @samp{/} on platforms where there is no difference. -The only options are @option{--help} and @option{--version}. @xref{Common -options}. Options must precede operands. +The program accepts the following options. Also see @ref{Common options}. +Options must precede operands. + +@table @samp + +@item -a +@itemx --multiple +@opindex -a +@opindex --multiple +Support more than one argument. Treat every argument as a @var{name}. +With this, an optional @var{suffix} must be specified using the +@option{-s} option. + +@item -s @var{suffix} +@itemx --suffix=@var{suffix} +@opindex -s +@opindex --suffix +Remove a trailing @var{suffix}. +This option implies the @option{-a} option. + +@item -z +@itemx --zero +@opindex -z +@opindex --zero +Separate output items with NUL characters. + +@end table @exitstatus @@ -12311,6 +12673,12 @@ basename /usr/bin/sort # Output "stdio". basename include/stdio.h .h + +# Output "stdio". +basename -s .h include/stdio.h + +# Output "stdio" followed by "stdlib" +basename -a -s .h include/stdio.h include/stdlib.h @end smallexample @@ -12322,13 +12690,13 @@ basename include/stdio.h .h @cindex stripping non-directory suffix @cindex non-directory suffix, stripping -@command{dirname} prints all but the final slash-delimited component of -@var{name}. Slashes on either side of the final component are also -removed. If the string contains no slash, @command{dirname} prints -@samp{.} (meaning the current directory). Synopsis: +@command{dirname} prints all but the final slash-delimited component +of each @var{name}. Slashes on either side of the final component are +also removed. If the string contains no slash, @command{dirname} +prints @samp{.} (meaning the current directory). Synopsis: @example -dirname @var{name} +dirname [@var{option}] @var{name}@dots{} @end example @var{name} need not be a file name, but if it is, this operation @@ -12337,13 +12705,22 @@ including the case when the final component is itself a directory. @basenameAndDirname -@acronym{POSIX} allows the implementation to define the results if -@var{name} is @samp{//}. With @acronym{GNU} @command{dirname}, the +POSIX allows the implementation to define the results if +@var{name} is @samp{//}. With GNU @command{dirname}, the result is @samp{//} on platforms where @var{//} is distinct from @var{/}, and @samp{/} on platforms where there is no difference. -The only options are @option{--help} and @option{--version}. @xref{Common -options}. +The program accepts the following option. Also see @ref{Common options}. + +@table @samp + +@item -z +@itemx --zero +@opindex -z +@opindex --zero +Separate output items with NUL characters. + +@end table @exitstatus @@ -12354,6 +12731,9 @@ Examples: dirname /usr/bin/sort dirname /usr/bin//.// +# Output "dir1" followed by "dir2" +dirname dir1/str dir2/str + # Output ".". dirname stdio.h @end smallexample @@ -12406,13 +12786,13 @@ print an error message if any of these conditions is true: A file name is empty. @item -A file name contains a character outside the @acronym{POSIX} portable file +A file name contains a character outside the POSIX portable file name character set, namely, the ASCII letters and digits, @samp{.}, @samp{_}, @samp{-}, and @samp{/}. @item The length of a file name or one of its components exceeds the -@acronym{POSIX} minimum limits for portability. +POSIX minimum limits for portability. @end enumerate @item -P @@ -12422,7 +12802,7 @@ that begins with @samp{-}. @item --portability @opindex --portability -Print an error message if a file name is not portable to all @acronym{POSIX} +Print an error message if a file name is not portable to all POSIX hosts. This option is equivalent to @samp{-p -P}. @end table @@ -12610,6 +12990,123 @@ Exit status: @end display +@node realpath invocation +@section @command{realpath}: Print the resolved file name. + +@pindex realpath +@cindex file names, canonicalization +@cindex symlinks, resolution +@cindex canonical file name +@cindex canonicalize a file name +@pindex realpath +@findex realpath + +@command{realpath} expands all symbolic links and resolves references to +@samp{/./}, @samp{/../} and extra @samp{/} characters. By default, +all but the last component of the specified files must exist. Synopsis: + +@example +realpath [@var{option}]@dots{} @var{file}@dots{} +@end example + +The program accepts the following options. Also see @ref{Common options}. + +@table @samp + +@item -e +@itemx --canonicalize-existing +@opindex -e +@opindex --canonicalize-existing +Ensure that all components of the specified file names exist. +If any component is missing or unavailable, @command{realpath} will output +a diagnostic unless the @option{-q} option is specified, and exit with a +nonzero exit code. A trailing slash requires that the name resolve to a +directory. + +@item -m +@itemx --canonicalize-missing +@opindex -m +@opindex --canonicalize-missing +If any component of a specified file name is missing or unavailable, +treat it as a directory. + +@item -L +@itemx --logical +@opindex -L +@opindex --logical +Symbolic links are resolved in the specified file names, +but they are resolved after any subsequent @samp{..} components are processed. + +@item -P +@itemx --physical +@opindex -P +@opindex --physical +Symbolic links are resolved in the specified file names, +and they are resolved before any subsequent @samp{..} components are processed. +This is the default mode of operation. + +@item -q +@itemx --quiet +@opindex -q +@opindex --quiet +Suppress diagnostic messages for specified file names. + +@item -s +@itemx --strip +@itemx --no-symlinks +@opindex -s +@opindex --strip +@opindex --no-symlinks +Do not resolve symbolic links. Only resolve references to +@samp{/./}, @samp{/../} and remove extra @samp{/} characters. +When combined with the @option{-m} option, realpath operates +only on the file name, and does not touch any actual file. + +@item -z +@itemx --zero +@opindex -z +@opindex --zero +Separate output items with NUL characters. + +@item --relative-to=@var{file} +@opindex --relative-to +@cindex relpath +Print the resolved file names relative to the specified file. +Note this option honors the @option{-m} and @option{-e} options +pertaining to file existence. + +@item --relative-base=@var{base} +@opindex --relative-base +This option is valid when used with @option{--relative-to}, and will restrict +the output of @option{--relative-to} so that relative names are output, +only when @var{file}s are descendants of @var{base}. Otherwise output the +absolute file name. If @option{--relative-to} was not specified, then +the descendants of @var{base} are printed relative to @var{base}. If +@option{--relative-to} is specified, then that directory must be a +descendant of @var{base} for this option to have an effect. +Note: this option honors the @option{-m} and @option{-e} +options pertaining to file existence. For example: + +@example +realpath --relative-to=/usr /tmp /usr/bin +@result{} ../tmp +@result{} bin +realpath --relative-base=/usr /tmp /usr/bin +@result{} /tmp +@result{} bin +@end example + +@end table + +@cindex exit status of @command{realpath} +Exit status: + +@display +0 if all file names were printed without issue. +1 otherwise. +@end display + + @node Working context @chapter Working context @@ -12717,8 +13214,8 @@ be used in combination with any line settings. @opindex --file Set the line opened by the file name specified in @var{device} instead of the tty line connected to standard input. This option is necessary -because opening a @acronym{POSIX} tty requires use of the -@code{O_NONDELAY} flag to prevent a @acronym{POSIX} tty from blocking +because opening a POSIX tty requires use of the +@code{O_NONDELAY} flag to prevent a POSIX tty from blocking until the carrier detect line is high if the @code{clocal} flag is not set. Hence, it is not always possible to allow the shell to open the device in the traditional manner. @@ -12740,9 +13237,9 @@ description. The descriptions themselves refer to the positive case, that is, when @emph{not} negated (unless stated otherwise, of course). -Some settings are not available on all @acronym{POSIX} systems, since they use +Some settings are not available on all POSIX systems, since they use extensions. Such arguments are marked below with -``Non-@acronym{POSIX}'' in their description. On non-@acronym{POSIX} +``Non-POSIX'' in their description. On non-POSIX systems, those or other settings also may not be available, but it's not feasible to document all the variations: just try it and see. @@ -12813,7 +13310,7 @@ Disable modem control signals. May be negated. @cindex hardware flow control @cindex flow control, hardware @cindex RTS/CTS flow control -Enable RTS/CTS flow control. Non-@acronym{POSIX}. May be negated. +Enable RTS/CTS flow control. Non-POSIX@. May be negated. @end table @@ -12893,20 +13390,20 @@ empty again. May be negated. @item iuclc @opindex iuclc @cindex uppercase, translating to lowercase -Translate uppercase characters to lowercase. Non-@acronym{POSIX}. May be -negated. Note ilcuc is not implemented, as one would not be able to issue +Translate uppercase characters to lowercase. Non-POSIX@. May be +negated. Note ilcuc is not implemented, as one would not be able to issue almost any (lowercase) Unix command, after invoking it. @item ixany @opindex ixany Allow any character to restart output (only the start character -if negated). Non-@acronym{POSIX}. May be negated. +if negated). Non-POSIX@. May be negated. @item imaxbel @opindex imaxbel @cindex beeping at input buffer full Enable beeping and not flushing input buffer if a character arrives -when the input buffer is full. Non-@acronym{POSIX}. May be negated. +when the input buffer is full. Non-POSIX@. May be negated. @end table @@ -12924,76 +13421,76 @@ Postprocess output. May be negated. @item olcuc @opindex olcuc @cindex lowercase, translating to output -Translate lowercase characters to uppercase. Non-@acronym{POSIX}. May be -negated. (Note ouclc is not currently implemented.) +Translate lowercase characters to uppercase. Non-POSIX@. May be +negated. (Note ouclc is not currently implemented.) @item ocrnl @opindex ocrnl @cindex return, translating to newline -Translate carriage return to newline. Non-@acronym{POSIX}. May be negated. +Translate carriage return to newline. Non-POSIX@. May be negated. @item onlcr @opindex onlcr @cindex newline, translating to crlf -Translate newline to carriage return-newline. Non-@acronym{POSIX}. May be +Translate newline to carriage return-newline. Non-POSIX@. May be negated. @item onocr @opindex onocr -Do not print carriage returns in the first column. Non-@acronym{POSIX}. +Do not print carriage returns in the first column. Non-POSIX@. May be negated. @item onlret @opindex onlret -Newline performs a carriage return. Non-@acronym{POSIX}. May be negated. +Newline performs a carriage return. Non-POSIX@. May be negated. @item ofill @opindex ofill @cindex pad instead of timing for delaying Use fill (padding) characters instead of timing for delays. -Non-@acronym{POSIX}. +Non-POSIX@. May be negated. @item ofdel @opindex ofdel @cindex pad character -Use @acronym{ASCII} @sc{del} characters for fill instead of -@acronym{ASCII} @sc{nul} characters. Non-@acronym{POSIX}. +Use ASCII DEL characters for fill instead of +ASCII NUL characters. Non-POSIX@. May be negated. @item nl1 @itemx nl0 @opindex nl@var{n} -Newline delay style. Non-@acronym{POSIX}. +Newline delay style. Non-POSIX. @item cr3 @itemx cr2 @itemx cr1 @itemx cr0 @opindex cr@var{n} -Carriage return delay style. Non-@acronym{POSIX}. +Carriage return delay style. Non-POSIX. @item tab3 @itemx tab2 @itemx tab1 @itemx tab0 @opindex tab@var{n} -Horizontal tab delay style. Non-@acronym{POSIX}. +Horizontal tab delay style. Non-POSIX. @item bs1 @itemx bs0 @opindex bs@var{n} -Backspace delay style. Non-@acronym{POSIX}. +Backspace delay style. Non-POSIX. @item vt1 @itemx vt0 @opindex vt@var{n} -Vertical tab delay style. Non-@acronym{POSIX}. +Vertical tab delay style. Non-POSIX. @item ff1 @itemx ff0 @opindex ff@var{n} -Form feed delay style. Non-@acronym{POSIX}. +Form feed delay style. Non-POSIX. @end table @@ -13015,7 +13512,7 @@ special characters. May be negated. @item iexten @opindex iexten -Enable non-@acronym{POSIX} special characters. May be negated. +Enable non-POSIX special characters. May be negated. @item echo @opindex echo @@ -13049,12 +13546,12 @@ characters. May be negated. @cindex case translation Enable input and output of uppercase characters by preceding their lowercase equivalents with @samp{\}, when @code{icanon} is set. -Non-@acronym{POSIX}. May be negated. +Non-POSIX@. May be negated. @item tostop @opindex tostop @cindex background jobs, stopping at terminal write -Stop background jobs that try to write to the terminal. Non-@acronym{POSIX}. +Stop background jobs that try to write to the terminal. Non-POSIX@. May be negated. @item echoprt @@ -13062,7 +13559,7 @@ May be negated. @opindex echoprt @opindex prterase Echo erased characters backward, between @samp{\} and @samp{/}. -Non-@acronym{POSIX}. May be negated. +Non-POSIX@. May be negated. @item echoctl @itemx ctlecho @@ -13071,7 +13568,7 @@ Non-@acronym{POSIX}. May be negated. @cindex control characters, using @samp{^@var{c}} @cindex hat notation for control characters Echo control characters in hat notation (@samp{^@var{c}}) instead -of literally. Non-@acronym{POSIX}. May be negated. +of literally. Non-POSIX@. May be negated. @item echoke @itemx crtkill @@ -13080,7 +13577,7 @@ of literally. Non-@acronym{POSIX}. May be negated. Echo the @code{kill} special character by erasing each character on the line as indicated by the @code{echoprt} and @code{echoe} settings, instead of by the @code{echoctl} and @code{echok} settings. -Non-@acronym{POSIX}. +Non-POSIX@. May be negated. @end table @@ -13168,18 +13665,18 @@ If negated, same as @code{parenb istrip opost cs7}. @item decctlq @opindex decctlq -Same as @option{-ixany}. Non-@acronym{POSIX}. May be negated. +Same as @option{-ixany}. Non-POSIX@. May be negated. @item tabs @opindex tabs -Same as @code{tab0}. Non-@acronym{POSIX}. May be negated. If negated, same +Same as @code{tab0}. Non-POSIX@. May be negated. If negated, same as @code{tab3}. @item lcase @itemx LCASE @opindex lcase @opindex LCASE -Same as @code{xcase iuclc olcuc}. Non-@acronym{POSIX}. May be negated. +Same as @code{xcase iuclc olcuc}. Non-POSIX@. May be negated. (Used for terminals with uppercase characters only.) @item crt @@ -13241,11 +13738,11 @@ End the line. @item eol2 @opindex eol2 -Alternate character to end the line. Non-@acronym{POSIX}. +Alternate character to end the line. Non-POSIX. @item swtch @opindex swtch -Switch to a different shell layer. Non-@acronym{POSIX}. +Switch to a different shell layer. Non-POSIX. @item start @opindex start @@ -13261,20 +13758,20 @@ Send a terminal stop signal. @item dsusp @opindex dsusp -Send a terminal stop signal after flushing the input. Non-@acronym{POSIX}. +Send a terminal stop signal after flushing the input. Non-POSIX. @item rprnt @opindex rprnt -Redraw the current line. Non-@acronym{POSIX}. +Redraw the current line. Non-POSIX. @item werase @opindex werase -Erase the last word typed. Non-@acronym{POSIX}. +Erase the last word typed. Non-POSIX. @item lnext @opindex lnext Enter the next character typed literally, even if it is a special -character. Non-@acronym{POSIX}. +character. Non-POSIX. @end table @@ -13305,13 +13802,13 @@ Set the output speed to @var{n}. @item rows @var{n} @opindex rows Tell the tty kernel driver that the terminal has @var{n} rows. -Non-@acronym{POSIX}. +Non-POSIX. @item cols @var{n} @itemx columns @var{n} @opindex cols @opindex columns -Tell the kernel that the terminal has @var{n} columns. Non-@acronym{POSIX}. +Tell the kernel that the terminal has @var{n} columns. Non-POSIX. @item size @opindex size @@ -13321,11 +13818,11 @@ Print the number of rows and columns that the kernel thinks the terminal has. (Systems that don't support rows and columns in the kernel typically use the environment variables @env{LINES} and @env{COLUMNS} instead; however, GNU @command{stty} does not know anything about them.) -Non-@acronym{POSIX}. +Non-POSIX. @item line @var{n} @opindex line -Use line discipline @var{n}. Non-@acronym{POSIX}. +Use line discipline @var{n}. Non-POSIX. @item speed @opindex speed @@ -13506,7 +14003,7 @@ Print the user or group name instead of the ID number. Requires @itemx --real @opindex -r @opindex --real -Print the real, instead of effective, user or group ID. Requires +Print the real, instead of effective, user or group ID@. Requires @option{-u}, @option{-g}, or @option{-G}. @item -u @@ -13568,7 +14065,7 @@ options}. @cindex printing the effective user ID @command{whoami} prints the user name associated with the current -effective user ID. It is equivalent to the command @samp{id -un}. +effective user ID@. It is equivalent to the command @samp{id -un}. The only options are @option{--help} and @option{--version}. @xref{Common options}. @@ -13712,7 +14209,7 @@ Print a line of column headings. List only the entries that correspond to processes via which the system is waiting for a user to login. The user name is always @samp{LOGIN}. -@itemx --lookup +@item --lookup @opindex --lookup Attempt to canonicalize hostnames found in utmp through a DNS lookup. This is not the default because it can cause significant delays on systems with @@ -13751,7 +14248,7 @@ Ignored; for compatibility with other versions of @command{who}. @opindex --time Print last system clock change. -@itemx -u +@item -u @opindex -u @cindex idle time After the login time, print the number of hours and minutes that the @@ -13870,37 +14367,38 @@ hour (@samp{00}@dots{}@samp{23}) @item %I hour (@samp{01}@dots{}@samp{12}) @item %k -hour (@samp{ 0}@dots{}@samp{23}). -This is a @acronym{GNU} extension. +hour, space padded (@samp{ 0}@dots{}@samp{23}); equivalent to @samp{%_H}@. +This is a GNU extension. @item %l -hour (@samp{ 1}@dots{}@samp{12}). -This is a @acronym{GNU} extension. +hour, space padded (@samp{ 1}@dots{}@samp{12}); equivalent to @samp{%_I}@. +This is a GNU extension. @item %M minute (@samp{00}@dots{}@samp{59}) @item %N nanoseconds (@samp{000000000}@dots{}@samp{999999999}). -This is a @acronym{GNU} extension. +This is a GNU extension. @item %p locale's equivalent of either @samp{AM} or @samp{PM}; blank in many locales. Noon is treated as @samp{PM} and midnight as @samp{AM}. @item %P like @samp{%p}, except lower case. -This is a @acronym{GNU} extension. +This is a GNU extension. @item %r locale's 12-hour clock time (e.g., @samp{11:11:04 PM}) @item %R 24-hour hour and minute. Same as @samp{%H:%M}. -This is a @acronym{GNU} extension. @item %s @cindex epoch, seconds since @cindex seconds since the epoch @cindex beginning of time -seconds since the epoch, i.e., since 1970-01-01 00:00:00 UTC. +@cindex leap seconds +seconds since the epoch, i.e., since 1970-01-01 00:00:00 UTC@. Leap seconds are not counted unless leap second support is available. @xref{%s-examples}, for examples. -This is a @acronym{GNU} extension. +This is a GNU extension. @item %S +@cindex leap seconds second (@samp{00}@dots{}@samp{60}). This may be @samp{60} if leap seconds are supported. @item %T @@ -13908,29 +14406,28 @@ This may be @samp{60} if leap seconds are supported. @item %X locale's time representation (e.g., @samp{23:13:48}) @item %z -@w{@acronym{RFC} 2822/@acronym{ISO} 8601} style numeric time zone +@w{RFC 2822/ISO 8601} style numeric time zone (e.g., @samp{-0600} or @samp{+0530}), or nothing if no time zone is determinable. This value reflects the numeric time zone appropriate for the current time, using the time zone rules specified by the @env{TZ} environment variable. The time (and optionally, the time zone rules) can be overridden by the @option{--date} option. -This is a @acronym{GNU} extension. @item %:z -@w{@acronym{RFC} 3339/@acronym{ISO} 8601} style numeric time zone with +@w{RFC 3339/ISO 8601} style numeric time zone with @samp{:} (e.g., @samp{-06:00} or @samp{+05:30}), or nothing if no time zone is determinable. -This is a @acronym{GNU} extension. +This is a GNU extension. @item %::z Numeric time zone to the nearest second with @samp{:} (e.g., @samp{-06:00:00} or @samp{+05:30:00}), or nothing if no time zone is determinable. -This is a @acronym{GNU} extension. +This is a GNU extension. @item %:::z Numeric time zone with @samp{:} using the minimum necessary precision (e.g., @samp{-06}, @samp{+05:30}, or @samp{-04:56:02}), or nothing if no time zone is determinable. -This is a @acronym{GNU} extension. +This is a GNU extension. @item %Z alphabetic time zone abbreviation (e.g., @samp{EDT}), or nothing if no time zone is determinable. See @samp{%z} for how it is determined. @@ -13968,28 +14465,25 @@ date; same as @samp{%m/%d/%y} @item %e day of month, space padded; same as @samp{%_d} @item %F -full date in @acronym{ISO} 8601 format; same as @samp{%Y-%m-%d}. +full date in ISO 8601 format; same as @samp{%Y-%m-%d}. This is a good choice for a date format, as it is standard and is easy to sort in the usual case where years are in the range 0000@dots{}9999. -This is a @acronym{GNU} extension. @item %g -year corresponding to the @acronym{ISO} week number, but without the century +year corresponding to the ISO week number, but without the century (range @samp{00} through @samp{99}). This has the same format and value -as @samp{%y}, except that if the @acronym{ISO} week number (see +as @samp{%y}, except that if the ISO week number (see @samp{%V}) belongs to the previous or next year, that year is used instead. -This is a @acronym{GNU} extension. @item %G -year corresponding to the @acronym{ISO} week number. This has the -same format and value as @samp{%Y}, except that if the @acronym{ISO} +year corresponding to the ISO week number. This has the +same format and value as @samp{%Y}, except that if the ISO week number (see @samp{%V}) belongs to the previous or next year, that year is used instead. It is normally useful only if @samp{%V} is also used; for example, the format @samp{%G-%m-%d} is probably a mistake, since it combines the ISO week number year with the conventional month and day. -This is a @acronym{GNU} extension. @item %h same as @samp{%b} @item %j @@ -14003,12 +14497,12 @@ week number of year, with Sunday as the first day of the week (@samp{00}@dots{}@samp{53}). Days in a new year preceding the first Sunday are in week zero. @item %V -@acronym{ISO} week number, that is, the +ISO week number, that is, the week number of year, with Monday as the first day of the week (@samp{01}@dots{}@samp{53}). If the week containing January 1 has four or more days in the new year, then it is considered week 1; otherwise, it is week 53 of -the previous year, and the next week is week 1. (See the @acronym{ISO} 8601 +the previous year, and the next week is week 1. (See the ISO 8601 standard.) @item %w day of week (@samp{0}@dots{}@samp{6}) with 0 corresponding to Sunday @@ -14058,7 +14552,7 @@ example, numeric months are always output as two digits. Seconds since the epoch are not padded, though, since there is no natural width for them. -As a @acronym{GNU} extension, @command{date} recognizes any of the +As a GNU extension, @command{date} recognizes any of the following optional flags after the @samp{%}: @table @samp @@ -14090,7 +14584,7 @@ date +%_d/%_m -d "Feb 1" @result{} 1/ 2 @end example -As a @acronym{GNU} extension, you can specify the field width +As a GNU extension, you can specify the field width (after any flag, if present) as a decimal number. If the natural size of the output of the field has less than the specified number of characters, the result is written right adjusted and padded to the given @@ -14127,11 +14621,9 @@ is available, it is ignored. If given an argument that does not start with @samp{+}, @command{date} sets the system clock to the date and time specified by that argument (as described below). You must have appropriate privileges to set the -system clock. The @option{--date} and @option{--set} options may not be -used with such an argument. The @option{--universal} option may be used -with such an argument to indicate that the specified date and time are -relative to Coordinated Universal Time rather than to the local time -zone. +system clock. Note for changes to persist across a reboot, the +hardware clock may need to be updated from the system clock, which +might not happen automatically on your system. The argument must consist entirely of digits, which have the following meaning: @@ -14153,7 +14645,10 @@ last two digits of year (optional) second (optional) @end table -The @option{--set} option also sets the system clock; see the next section. +Note, the @option{--date} and @option{--set} options may not be used with an +argument in the above format. The @option{--universal} option may be used +with such an argument to indicate that the specified date and time are +relative to Coordinated Universal Time rather than to the local time zone. @node Options for date @@ -14183,8 +14678,8 @@ format. It can contain month names, time zones, @samp{am} and @samp{pm}, @samp{yesterday}, etc. For example, @option{--date="2004-02-27 14:19:13.489392193 +0530"} specifies the instant of time that is 489,392,193 nanoseconds after February 27, 2004 at 2:19:13 PM in a -time zone that is 5 hours and 30 minutes east of @acronym{UTC}.@* -Note: input currently must be in locale independent format. E.g., the +time zone that is 5 hours and 30 minutes east of UTC.@* +Note: input currently must be in locale independent format. E.g., the LC_TIME=C below is needed to print back the correct date in many locales: @example date -d "$(LC_TIME=C date)" @@ -14201,6 +14696,34 @@ input. This is useful when you have many dates to process, because the system overhead of starting up the @command{date} executable many times can be considerable. +@item -I[@var{timespec}] +@itemx --iso-8601[=@var{timespec}] +@opindex -I[@var{timespec}] +@opindex --iso-8601[=@var{timespec}] +Display the date using the ISO 8601 format, @samp{%Y-%m-%d}. + +The argument @var{timespec} specifies the number of additional +terms of the time to include. It can be one of the following: +@table @samp +@item auto +Print just the date. This is the default if @var{timespec} is omitted. + +@item hours +Append the hour of the day to the date. + +@item minutes +Append the hours and minutes. + +@item seconds +Append the hours, minutes and seconds. + +@item ns +Append the hours, minutes, seconds and nanoseconds. +@end table + +If showing any time terms, then include the time zone using the format +@samp{%z}. + @item -r @var{file} @itemx --reference=@var{file} @opindex -r @@ -14224,7 +14747,7 @@ Fri, 09 Sep 2005 13:51:39 -0700 This format conforms to @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2822.txt, Internet -@acronym{RFCs} 2822} and +RFCs 2822} and @uref{ftp://ftp.rfc-editor.org/in-notes/rfc822.txt, 822}, the current and previous standards for Internet email. @@ -14232,10 +14755,10 @@ current and previous standards for Internet email. @opindex --rfc-3339=@var{timespec} Display the date using a format specified by @uref{ftp://ftp.rfc-editor.org/in-notes/rfc3339.txt, Internet -@acronym{RFC} 3339}. This is a subset of the @acronym{ISO} 8601 +RFC 3339}. This is a subset of the ISO 8601 format, except that it also permits applications to use a space rather than a @samp{T} to separate dates from times. Unlike the other -standard formats, @acronym{RFC} 3339 format is always suitable as +standard formats, RFC 3339 format is always suitable as input for the @option{--date} (@option{-d}) and @option{--file} (@option{-f}) options, regardless of the current locale. @@ -14251,7 +14774,7 @@ This is equivalent to the format @samp{%Y-%m-%d}. Print the full-date and full-time separated by a space, e.g., @samp{2005-09-14 00:56:06+05:30}. The output ends with a numeric time-offset; here the @samp{+05:30} means that local time is five -hours and thirty minutes east of @acronym{UTC}. This is equivalent to +hours and thirty minutes east of UTC@. This is equivalent to the format @samp{%Y-%m-%d %H:%M:%S%:z}. @item ns @@ -14266,6 +14789,7 @@ This is equivalent to the format @samp{%Y-%m-%d %H:%M:%S.%N%:z}. @opindex -s @opindex --set Set the date and time to @var{datestr}. See @option{-d} above. +See also @ref{Setting the time}. @item -u @itemx --utc @@ -14277,12 +14801,15 @@ Set the date and time to @var{datestr}. See @option{-d} above. @cindex UTC @cindex Greenwich Mean Time @cindex GMT +@cindex leap seconds @vindex TZ -Use Coordinated Universal Time (@acronym{UTC}) by operating as if the +Use Coordinated Universal Time (UTC) by operating as if the @env{TZ} environment variable were set to the string @samp{UTC0}. Coordinated -Universal Time is often called ``Greenwich Mean Time'' (@sc{gmt}) for +Universal Time is often called ``Greenwich Mean Time'' (GMT) for historical reasons. +Typically, systems ignore leap seconds and thus implement an +approximation to UTC rather than true UTC. @end table @@ -14330,7 +14857,7 @@ for example @samp{date -d 1may '+%B %d'} will print @samp{May 01}. @item To print a date without the leading zero for one-digit days -of the month, you can use the (@acronym{GNU} extension) +of the month, you can use the (GNU extension) @samp{-} flag to suppress the padding altogether: @@ -14340,7 +14867,7 @@ date -d 1may '+%B %-d @item To print the current date and time in the format required by many -non-@acronym{GNU} versions of @command{date} when setting the system clock: +non-GNU versions of @command{date} when setting the system clock: @example date +%m%d%H%M%Y.%S @@ -14354,7 +14881,7 @@ date --set='+2 minutes' @end example @item -To print the date in @acronym{RFC} 2822 format, +To print the date in RFC 2822 format, use @samp{date --rfc-2822}. Here is some example output: @example @@ -14433,6 +14960,36 @@ date -u -d '1970-01-01 946684800 seconds' +"%Y-%m-%d %T %z" 2000-01-01 00:00:00 +0000 @end smallexample +@item +@cindex leap seconds +Typically the seconds count omits leap seconds, but some systems are +exceptions. Because leap seconds are not predictable, the mapping +between the seconds count and a future timestamp is not reliable on +the atypical systems that include leap seconds in their counts. + +Here is how the two kinds of systems handle the leap second at +2012-06-30 23:59:60 UTC: + +@example +# Typical systems ignore leap seconds: +date --date='2012-06-30 23:59:59 +0000' +%s +1341100799 +date --date='2012-06-30 23:59:60 +0000' +%s +date: invalid date '2012-06-30 23:59:60 +0000' +date --date='2012-07-01 00:00:00 +0000' +%s +1341100800 +@end example + +@example +# Atypical systems count leap seconds: +date --date='2012-06-30 23:59:59 +0000' +%s +1341100823 +date --date='2012-06-30 23:59:60 +0000' +%s +1341100824 +date --date='2012-07-01 00:00:00 +0000' +%s +1341100825 +@end example + @end itemize @@ -14522,7 +15079,7 @@ parsed reliably. In the following example, @var{release} is @smallexample uname -a -@result{} Linux dum 2.2.18 #4 SMP Tue Jun 5 11:24:08 PDT 2001 i686@c +@result{} Linux dumdum 2.2.18 #4 SMP Tue Jun 5 11:24:08 PDT 2001 i686@c unknown unknown GNU/Linux @end smallexample @@ -14601,9 +15158,9 @@ Print the kernel release. @cindex kernel name @cindex name of kernel Print the kernel name. -@acronym{POSIX} 1003.1-2001 (@pxref{Standards conformance}) calls this +POSIX 1003.1-2001 (@pxref{Standards conformance}) calls this ``the implementation of the operating system'', because the -@acronym{POSIX} specification itself has no notion of ``kernel''. +POSIX specification itself has no notion of ``kernel''. The kernel name might be the same as the operating system name printed by the @option{-o} or @option{--operating-system} option, but it might differ. Some operating systems (e.g., FreeBSD, HP-UX) have the same @@ -14742,12 +15299,16 @@ The program accepts the following options. Also see @ref{Common options}. @table @samp +@item --dereference +@opindex --dereference +Do not affect symbolic links but what they refer to; this is the default. + @item -h @itemx --no-dereference @opindex -h @opindex --no-dereference @cindex no dereference -Affect symbolic links instead of any referenced file. +Affect the symbolic links themselves instead of any referenced file. @item --reference=@var{rfile} @opindex --reference @@ -14760,6 +15321,18 @@ Use @var{rfile}'s security context rather than specifying a @var{context} value. @opindex --recursive Operate on files and directories recursively. +@item --preserve-root +@opindex --preserve-root +Refuse to operate recursively on the root directory, @file{/}, +when used together with the @option{--recursive} option. +@xref{Treating / specially}. + +@item --no-preserve-root +@opindex --no-preserve-root +Do not treat the root directory, @file{/}, specially when operating +recursively; this is the default. +@xref{Treating / specially}. + @choptH @xref{Traversing symlinks}. @@ -14894,7 +15467,6 @@ user, etc. * nice invocation:: Modify niceness. * nohup invocation:: Immunize to hangups. * stdbuf invocation:: Modify buffering of standard streams. -* su invocation:: Modify user and group ID. * timeout invocation:: Run with time limit. @end menu @@ -14933,14 +15505,14 @@ Options must precede operands. @table @samp -@itemx --userspec=@var{user}[:@var{group}] +@item --userspec=@var{user}[:@var{group}] @opindex --userspec By default, @var{command} is run with the same credentials as the invoking process. Use this option to run it as a different @var{user} and/or with a different primary @var{group}. -@itemx --groups=@var{groups} +@item --groups=@var{groups} @opindex --groups Use this option to specify the supplementary @var{groups} to be used by the new process. @@ -15011,9 +15583,9 @@ These operands are evaluated left-to-right, so if two operands mention the same variable the earlier is ignored. Environment variable names can be empty, and can contain any -characters other than @samp{=} and @acronym{ASCII} @sc{nul}. +characters other than @samp{=} and ASCII NUL. However, it is wise to limit yourself to names that -consist solely of underscores, digits, and @acronym{ASCII} letters, +consist solely of underscores, digits, and ASCII letters, and that begin with a non-digit, as applications like the shell do not work well with other names. @@ -15145,8 +15717,9 @@ the exit status of @var{command} otherwise @cindex scheduling, affecting @cindex appropriate privileges -@command{nice} prints or modifies a process's @dfn{niceness}, -a parameter that affects whether the process is scheduled favorably. +@command{nice} prints a process's @dfn{niceness}, or runs +a command with modified niceness. @dfn{niceness} affects how +favorably the process is scheduled in the system. Synopsis: @example @@ -15161,7 +15734,7 @@ Niceness values range at least from @minus{}20 (process has high priority and gets more resources, thus slowing down other processes) through 19 (process has lower priority and runs slowly itself, but has less impact on the speed of other running processes). Some systems -may have a wider range of nicenesses; conversely, other systems may +may have a wider range of niceness values; conversely, other systems may enforce more restrictive limits. An attempt to set the niceness outside the supported range is treated as an attempt to use the minimum or maximum supported value. @@ -15170,10 +15743,10 @@ A niceness should not be confused with a scheduling priority, which lets applications determine the order in which threads are scheduled to run. Unlike a priority, a niceness is merely advice to the scheduler, which the scheduler is free to ignore. Also, as a point of -terminology, @acronym{POSIX} defines the behavior of @command{nice} in +terminology, POSIX defines the behavior of @command{nice} in terms of a @dfn{nice value}, which is the nonnegative difference between a niceness and the minimum niceness. Though @command{nice} -conforms to @acronym{POSIX}, its documentation and diagnostics use the +conforms to POSIX, its documentation and diagnostics use the term ``niceness'' for compatibility with historical practice. @var{command} must not be a special built-in utility (@pxref{Special @@ -15181,6 +15754,9 @@ built-in utilities}). @mayConflictWithShellBuiltIn{nice} +Note to change the @dfn{niceness} of an existing process, +one needs to use the @command{renice} command. + The program accepts the following option. Also see @ref{Common options}. Options must precede operands. @@ -15279,8 +15855,8 @@ nohup @var{command} [@var{arg}]@dots{} If standard input is a terminal, it is redirected from @file{/dev/null} so that terminal sessions do not mistakenly consider -the terminal to be used by the command. This is a @acronym{GNU} -extension; programs intended to be portable to non-@acronym{GNU} hosts +the terminal to be used by the command. This is a GNU +extension; programs intended to be portable to non-GNU hosts should use @samp{nohup @var{command} [@var{arg}]@dots{}