📄 coreutils.texi
字号:
@cindex mebibyte, definition ofmebibyte: @math{2^20 = 1,048,576}.@item GB@cindex gigabyte, definition ofgigabyte: @math{10^9 = 1,000,000,000}.@item G@itemx GiB@cindex gibibyte, definition ofgibibyte: @math{2^30 = 1,073,741,824}.@item TB@cindex terabyte, definition ofterabyte: @math{10^12 = 1,000,000,000,000}.@item T@itemx TiB@cindex tebibyte, definition oftebibyte: @math{2^40 = 1,099,511,627,776}.@item PB@cindex petabyte, definition ofpetabyte: @math{10^15 = 1,000,000,000,000,000}.@item P@itemx PiB@cindex pebibyte, definition ofpebibyte: @math{2^50 = 1,125,899,906,842,624}.@item EB@cindex exabyte, definition ofexabyte: @math{10^18 = 1,000,000,000,000,000,000}.@item E@itemx EiB@cindex exbibyte, definition ofexbibyte: @math{2^60 = 1,152,921,504,606,846,976}.@item ZB@cindex zettabyte, definition ofzettabyte: @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 GNU extension to IEC 60027-2.)@item YB@cindex yottabyte, definition ofyottabyte: @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 GNU extension to IEC 60027-2.)@end table@opindex -k@opindex -h@opindex --block-size@opindex --human-readable@opindex --siBlock size defaults can be overridden by an explicit@option{--block-size=@var{size}} option. The @option{-k}option is equivalent to @option{--block-size=1K}, whichis the default unless the @env{POSIXLY_CORRECT} environment variable isset. The @option{-h} or @option{--human-readable} option is equivalent to@option{--block-size=human-readable}. The @option{--si} option isequivalent to @option{--block-size=si}.@node Target directory@section Target directory@cindex target directorySome @sc{gnu} programs (at least @command{cp}, @code{install}, @code{ln}, and@command{mv}) allow you to specify the target directory via this option:@table @samp@itemx @w{@kbd{--target-directory}=@var{directory}}@opindex --target-directory@cindex target directory@cindex destination directorySpecify the destination @var{directory}.The interface for most programs is that after processing options and afinite (possibly zero) number of fixed-position arguments, the remainingargument list is either expected to be empty, or is a list of items(usually files) that will all be handled identically. The @code{xargs}program is designed to work well with this convention.The commands in the @command{mv}-family are unusual in that they takea variable number of arguments with a special case at the @emph{end}(namely, the target directory). This makes it nontrivial to perform someoperations, e.g., ``move all files from here to ../d/'', because@code{mv * ../d/} might exhaust the argument space, and @code{ls | xargs ...}doesn't have a clean way to specify an extra final argument for eachinvocation of the subject command. (It can be done by going through ashell command, but that requires more human labor and brain power thanit should.)The @w{@kbd{--target-directory}} option allows the @command{cp},@command{install}, @code{ln}, and @code{mv} programs to be used convenientlywith @code{xargs}. For example, you can move the files from thecurrent directory to a sibling directory, @code{d} like this:(However, this doesn't move files whose names begin with @samp{.}.)@smallexamplels |xargs mv --target-directory=../d@end smallexampleIf you use the @sc{gnu} @code{find} program, you can move @emph{all}files with this command:@examplefind . -mindepth 1 -maxdepth 1 \ | xargs mv --target-directory=../d@end exampleBut that will fail if there are no files in the current directoryor if any file has a name containing a newline character.The following example removes those limitations and requires both@sc{gnu} @code{find} and @sc{gnu} @code{xargs}:@examplefind . -mindepth 1 -maxdepth 1 -print0 \ | xargs --null --no-run-if-empty \ mv --target-directory=../d@end example@end table@node Trailing slashes@section Trailing slashes@cindex trailing slashesSome @sc{gnu} programs (at least @command{cp} and @code{mv}) allow you toremove any trailing slashes from each @var{source} argument beforeoperating on it. The @w{@kbd{--strip-trailing-slashes}} option enablesthis behavior.This is useful when a @var{source} argument may have a trailing slash andspecify a symbolic link to a directory. This scenario is in fact rathercommon because some shells can automatically append a trailing slash whenperforming file name completion on such symbolic links. Without thisoption, @command{mv}, for example, (via the system's rename function) mustinterpret a trailing slash as a request to dereference the symbolic linkand so must rename the indirectly referenced @emph{directory} and notthe symbolic link. Although it may seem surprising that such behaviorbe the default, it is required by @acronym{POSIX} and is consistent withother parts of that standard.@node Standards conformance@section Standards conformance@vindex POSIXLY_CORRECTIn a few cases, the @sc{gnu} utilities' default behavior isincompatible with the @acronym{POSIX} standard. To suppress theseincompatibilities, define the @env{POSIXLY_CORRECT} environmentvariable. Unless you are checking for @acronym{POSIX} conformance, youprobably do not need to define @env{POSIXLY_CORRECT}.Newer versions of @acronym{POSIX} are occasionally incompatible with olderversions. For example, older versions of @acronym{POSIX} required thecommand @samp{sort +1} to sort based on the second and succeedingfields in each input line, but starting with @acronym{POSIX} 1003.1-2001the same command is required to sort the file named @file{+1}, and youmust instead use the command @samp{sort -k 2} to get the field-basedsort.@vindex _POSIX2_VERSIONThe @sc{gnu} utilities normally conform to the version of @acronym{POSIX}that is standard for your system. To cause them to conform to adifferent version of @acronym{POSIX}, define the @env{_POSIX2_VERSION}environment variable to a value of the form @var{yyyymm} specifyingthe year and month the standard was adopted. Two values are currentlysupported for @env{_POSIX2_VERSION}: @samp{199209} stands for@acronym{POSIX} 1003.2-1992, and @samp{200112} stands for @acronym{POSIX}1003.1-2001. For example, if you are running older software thatassumes an older version of @acronym{POSIX} and uses @samp{sort +1}, youcan work around the compatibility problems by setting@samp{_POSIX2_VERSION=199209} in your environment.@node Output of entire files@chapter Output of entire files@cindex output of entire files@cindex entire files, output ofThese commands read and write entire files, possibly transforming themin some way.@menu* cat invocation:: Concatenate and write files.* tac invocation:: Concatenate and write files in reverse.* nl invocation:: Number lines and write files.* od invocation:: Write files in octal or other formats.@end menu@node cat invocation@section @command{cat}: Concatenate and write files@pindex cat@cindex concatenate and write files@cindex copying files@command{cat} copies each @var{file} (@samp{-} means standard input), orstandard input if none are given, to standard output. Synopsis:@examplecat [@var{option}] [@var{file}]@dots{}@end exampleThe program accepts the following options. Also see @ref{Common options}.@table @samp@item -A@itemx --show-all@opindex -A@opindex --show-allEquivalent to @option{-vET}.@item -B@itemx --binary@opindex -B@opindex --binary@cindex binary and text I/O in catOn MS-DOS and MS-Windows only, read and write the files in binary mode.By default, @command{cat} on MS-DOS/MS-Windows uses binary mode only whenstandard output is redirected to a file or a pipe; this option overridesthat. Binary file I/O is used so that the files retain their format(Unix text as opposed to DOS text and binary), because @command{cat} isfrequently used as a file-copying program. Some options (see below)cause @command{cat} to read and write files in text mode because in thosecases the original file contents aren't important (e.g., when lines arenumbered by @command{cat}, or when line endings should be marked). This isso these options work as DOS/Windows users would expect; for example,DOS-style text files have their lines end with the CR-LF pair ofcharacters, which won't be processed as an empty line by @option{-b} unlessthe file is read in text mode.@item -b@itemx --number-nonblank@opindex -b@opindex --number-nonblankNumber all nonblank output lines, starting with 1. On MS-DOS andMS-Windows, this option causes @command{cat} to read and write files intext mode.@item -e@opindex -eEquivalent to @option{-vE}.@item -E@itemx --show-ends@opindex -E@opindex --show-endsDisplay a @samp{$} after the end of each line. On MS-DOS andMS-Windows, this option causes @command{cat} to read and write files intext mode.@item -n@itemx --number@opindex -n@opindex --numberNumber all output lines, starting with 1. On MS-DOS and MS-Windows,this option causes @command{cat} to read and write files in text mode.@item -s@itemx --squeeze-blank@opindex -s@opindex --squeeze-blank@cindex squeezing blank linesReplace multiple adjacent blank lines with a single blank line. OnMS-DOS and MS-Windows, this option causes @command{cat} to read and writefiles in text mode.@item -t@opindex -tEquivalent to @option{-vT}.@item -T@itemx --show-tabs@opindex -T@opindex --show-tabsDisplay TAB characters as @samp{^I}.@item -u@opindex -uIgnored; for Unix compatibility.@item -v@itemx --show-nonprinting@opindex -v@opindex --show-nonprintingDisplay control characters except for LFD and TAB using@samp{^} notation and precede characters that have the high bit set with@samp{M-}. On MS-DOS and MS-Windows, this option causes @command{cat} toread files and standard input in DOS binary mode, so the CRcharacters at the end of each line are also visible.@end table@node tac invocation@section @command{tac}: Concatenate and write files in reverse@pindex tac@cindex reversing files@command{tac} copies each @var{file} (@samp{-} means standard input), orstandard input if none are given, to standard output, reversing therecords (lines by default) in each separately. Synopsis:@exampletac [@var{option}]@dots{} [@var{file}]@dots{}@end example@dfn{Records} are separated by instances of a string (newline bydefault). By default, this separator string is attached to the end ofthe record that it follows in the file.The program accepts the following options. Also see @ref{Common options}.@table @samp@item -b@itemx --before@opindex -b@opindex --beforeThe separator is attached to the beginning of the record that itprecedes in the file.@item -r@itemx --regex@opindex -r@opindex --regexTreat the separator string as a regular expression. Users of @command{tac}on MS-DOS/MS-Windows should note that, since @command{tac} reads files inbinary mode, each line of a text file might end with a CR/LF pairinstead of the Unix-style LF.@item -s @var{separator}@itemx --separator=@var{separator}@opindex -s@opindex --separatorUse @var{separator} as the record separator, instead of newline.@end table@node nl invocation@section @command{nl}: Number lines and write files@pindex nl@cindex numbering lines@cindex line numbering@command{nl} writes each @var{file} (@samp{-} means standard input), orstandard input if none are given, to standard output, with line numbersadded to some or all of the lines. Synopsis:@examplenl [@var{option}]@dots{} [@var{file}]@dots{}@end example@cindex logical pages, numbering on@command{nl} decomposes its input into (logical) pages; by default, theline number is reset to 1 at the top of each logical page. @command{nl}treats all of the input files as a single document; it does not reset
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -