]> gnu Coreutils This manual documents version 6.9 of the gnu coreutilities, including the standard programs for text and file manipulation.Copyright © 1994, 1995, 1996, 2000, 2001, 2002, 2003, 2004,2005, 2006 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”. GNU Coreutils This manual documents version 6.9 of the gnu core utilities, including the standard programs for text and file manipulation. Copyright © 1994, 1995, 1996, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”. core utilities text utilities shell utilities file utilities Introduction 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 gnu community will benefit. POSIX The gnu utilities documented here are mostly compatible with the POSIX standard. bugs, reporting Please report bugs to . Remember to include the version number, machine architecture, input files, and any other information needed to reproduce the bug: your input, what you expected, what you got, and why it is wrong. Diffs are welcome, but please include a description of the problem as well, since this is sometimes difficult to infer. See See section ``Bugs'' in Using and Porting GNU CC. Berry, K. Paterson, R. Stallman, R. Pinard, F. MacKenzie, D. Meyering, J. Youmans, B. This manual was originally derived from the Unix man pages in the distributions, which were written by David MacKenzie and updated by Jim Meyering. What you are reading now is the authoritative documentation for these utilities; the man pages are no longer being maintained. The original fmt man page was written by Ross Paterson. François Pinard did the initial conversion to Texinfo format. Karl Berry did the indexing, some reorganization, and editing of the results. Brian Youmans of the Free Software Foundation office staff combined the manuals for textutils, fileutils, and sh-utils to produce the present omnibus manual. Richard Stallman contributed his usual invaluable insights to the overall process. Common options common options 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 gnu program accepts (or should accept) these options.) POSIXLY_CORRECT Normally options and operands can appear in any order, and programs act as if all the options appear before any operands. For example, ‘sort -r passwd -t :’ acts like ‘sort -r -t : passwd’, since ‘:’ is an option-argument of . However, if the POSIXLY_CORRECT environment variable is set, options must appear before operands, unless otherwise specified for a particular command. A few programs can usefully have trailing operands with leading ‘-’. With such a program, options must precede operands even if POSIXLY_CORRECT is not set, and this fact is noted in the program description. For example, the env command's options must appear before its operands, since in some cases the operands specify a command that itself contains options. Some of these programs recognize the and options only when one of them is the sole command line argument. --help –help help, onlinePrint a usage message listing all available options, then exit successfully. --version –version version number, findingPrint the version number, then exit successfully. -- option delimiterDelimit the option list. Later arguments, if any, are treated asoperands even if they begin with ‘-’. For example, ‘sort ---r’ reads from the file named -r. standard input standard output A single ‘-’ operand is not really an option, though it looks like one. It stands for standard input, or for standard output if that is clear from the context. For example, ‘sort -’ reads from standard input, and is equivalent to plain ‘sort’, and ‘tee -’ writes an extra copy of its input to standard output. Unless otherwise specified, ‘-’ can appear as any operand that requires a file name. Exit status Nearly every command invocation yields an integral 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 ‘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 other exit status values and a few associate different meanings with the values ‘0’ and ‘1’. Here are some of the exceptions: chroot, env, expr, nice, nohup, printenv, sort, su, test, tty. Backup options backup options Some gnu programs (at least cp, install, ln, and mv) optionally make backups of files before writing new versions. These options control the details of these backups. The options are also briefly mentioned in the descriptions of the particular programs. -b’‘--backup[=method] -b –backup VERSION_CONTROL backups, makingMake a backup of each file that would otherwise be overwritten or removed.Without this option, the original versions are destroyed.Use method to determine the type of backups to make.When this option is used but method is not specified,then the value of the VERSION_CONTROLenvironment variable is used. And if VERSION_CONTROL is not set,the default backup type is ‘existing’.Note that the short form of this option, does not accept anyargument. Using is equivalent to using . version-control Emacs variableThis option corresponds to the Emacs variable ‘version-control’;the values for method are the same as those used in Emacs.This option also accepts more descriptive names.The valid methods are (unique abbreviations are accepted): none’‘off none backup methodNever make backups. numbered’‘t numbered backup methodAlways make numbered backups. existing’‘nil existing backup methodMake numbered backups of files that already have them, simple backupsof the others. simple’‘never simple backup methodAlways make simple backups. Please note ‘never’ is not to beconfused with ‘none’. -S suffix’‘--suffix=suffix -S –suffix backup suffix SIMPLE_BACKUP_SUFFIXAppend suffix to each backup file made with . If thisoption is not specified, the value of the SIMPLE_BACKUP_SUFFIXenvironment variable is used. And if SIMPLE_BACKUP_SUFFIX is notset, the default is ‘~’, just as in Emacs. Block size block size Some gnu programs (at least df, du, and 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. Fractional block counts are rounded up to the nearest integer. –block-size=size BLOCKSIZE BLOCK_SIZE DF_BLOCK_SIZE DU_BLOCK_SIZE LS_BLOCK_SIZE POSIXLY_CORRECT, and block size The default block size is chosen by examining the following environment variables in turn; the first one that is set determines the block size. DF_BLOCK_SIZE This specifies the default block size for the df command.Similarly, DU_BLOCK_SIZE specifies the default for du andLS_BLOCK_SIZE for ls. BLOCK_SIZE This specifies the default block size for all three commands, if theabove command-specific environment variables are not set. BLOCKSIZE This specifies the default block size for all values that are normallyprinted as blocks, if neither BLOCK_SIZE nor the abovecommand-specific environment variables are set. Unlike the otherenvironment variables, BLOCKSIZE does not affect values that arenormally printed as byte counts, e.g., the file sizes contained inls -l output. POSIXLY_CORRECT If neither command_BLOCK_SIZE, nor BLOCK_SIZE, norBLOCKSIZE is set, but this variable is set, the block sizedefaults to 512. If none of the above environment variables are set, the block size currently defaults to 1024 bytes in most contexts, but this number may change in the future. For ls file sizes, the block size defaults to 1 byte. human-readable output SI output A block size specification can be a positive integer specifying the number of bytes per block, or it can be human-readable or si to select a human-readable format. Integers may be followed by suffixes that are upward compatible with the SI prefixes for decimal multiples and with the IEC 60027-2 prefixes for binary multiples. With human-readable formats, output sizes are followed by a size letter such as ‘M’ for megabytes. BLOCK_SIZE=human-readable uses powers of 1024; ‘M’ stands for 1,048,576 bytes. BLOCK_SIZE=si is similar, but uses powers of 1000 and appends ‘B’; ‘MB’ stands for 1,000,000 bytes. LC_NUMERIC A block size specification preceded by ‘'’ causes output sizes to be displayed with thousands separators. The LC_NUMERIC locale specifies the thousands separator and grouping. For example, in an American English locale, ‘--block-size="'1kB"’ would cause a size of 1234000 bytes to be displayed as ‘1,234’. In the default C locale, there is no thousands separator so a leading ‘'’ has no effect. An integer block size can be followed by a suffix to specify a multiple of that size. A bare size letter, or one followed by ‘iB’, specifies a multiple using powers of 1024. A size letter followed by ‘B’ specifies powers of 1000 instead. For example, ‘1M’ and ‘1MiB’ are equivalent to ‘1048576’, whereas ‘1MB’ is equivalent to ‘1000000’. A plain suffix without a preceding integer acts as if ‘1’ were prepended, except that it causes a size indication to be appended to the output. For example, ‘--block-size="kB"’ displays 3000 as ‘3kB’. The following suffixes are defined. Large sizes like 1Y may be rejected by your computer due to limitations of its arithmetic. kB kilobyte, definition ofkilobyte: 10^3 = 1000. k’‘K’‘KiB kibibyte, definition ofkibibyte: 2^10 = 1024. ‘K’ is special: the SI prefix is‘k’ and the IEC 60027-2 prefix is ‘Ki’, but tradition andPOSIX use ‘k’ to mean ‘KiB’. MB megabyte, definition ofmegabyte: 10^6 = 1,000,000. M’‘MiB mebibyte, definition ofmebibyte: 2^20 = 1,048,576. GB gigabyte, definition ofgigabyte: 10^9 = 1,000,000,000. G’‘GiB gibibyte, definition ofgibibyte: 2^30 = 1,073,741,824. TB terabyte, definition ofterabyte: 10^12 = 1,000,000,000,000. T’‘TiB tebibyte, definition oftebibyte: 2^40 = 1,099,511,627,776. PB petabyte, definition ofpetabyte: 10^15 = 1,000,000,000,000,000. P’‘PiB pebibyte, definition ofpebibyte: 2^50 = 1,125,899,906,842,624. EB exabyte, definition ofexabyte: 10^18 = 1,000,000,000,000,000,000. E’‘EiB exbibyte, definition ofexbibyte: 2^60 = 1,152,921,504,606,846,976. ZB zettabyte, definition ofzettabyte: 10^21 = 1,000,000,000,000,000,000,000 Z’‘ZiB2^70 = 1,180,591,620,717,411,303,424.(‘Zi’ is a GNU extension to IEC 60027-2.) YB yottabyte, definition ofyottabyte: 10^24 = 1,000,000,000,000,000,000,000,000. Y’‘YiB2^80 = 1,208,925,819,614,629,174,706,176.(‘Yi’ is a GNU extension to IEC 60027-2.) -k -h –block-size –human-readable –si Block size defaults can be overridden by an explicit option. The option is equivalent to , which is the default unless the POSIXLY_CORRECT environment variable is set. The or option is equivalent to . The option is equivalent to . chown and chgrp: Disambiguating user names and IDs user names, disambiguating user IDs, disambiguating group names, disambiguating group IDs, disambiguating disambiguating group names and IDs Since the owner and group arguments to chown and chgrp may be specified as names or numeric IDs, there is an apparent ambiguity. What if a user or group name is a string of digits? 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? POSIX requires that chown and chgrp first attempt to resolve the specified string as a name, and 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 ‘42’ is a user name that maps to some other user ID, say 1000. Simply invoking chown 42 F, will set Fs owner ID to 1000—not what you intended. GNU chown and chgrp provide a way to work around this, that at the same time may result in a significant performance improvement by eliminating a database look-up. Simply precede each numeric user ID and/or group ID with a ‘+’, in order to force its interpretation as an integer: chown +42 F chgrp +$numeric_group_id another-file chown +0:+0 / GNU chown and chgrp skip the name look-up process for each ‘+’-prefixed string, because a string containing ‘+’ is never a valid user or group name. This syntax is accepted on most common Unix systems, but not on Solaris 10. Sources of random data random sources The shuf, shred, and sort commands sometimes need random data to do their work. For example, ‘sort -R’ must choose a hash function at random, and it needs random data to make this selection. Normally these commands use the device file /dev/urandom as the source of random data. Typically, this device gathers environmental noise from device drivers and other sources into an entropy pool, and uses the pool to generate random bits. If the pool is short of data, the device reuses the internal pool to produce more bits, using a cryptographically secure pseudorandom number generator. /dev/urandom suffices for most practical uses, but applications requiring high-value or long-term protection of private data may require an alternate data source like /dev/random or /dev/arandom. The set of available sources depends on your operating system. To use such a source, specify the option, e.g., ‘shuf --random-source=/dev/random’. The contents of file should be as random as possible. An error is reported if file does not contain enough bytes to randomize the input adequately. To reproduce the results of an earlier invocation of a command, you can save some random data into a file and then use that file as the random source in earlier and later invocations of the command. Some old-fashioned or stripped-down operating systems lack support for /dev/urandom. On these systems commands like shuf by default fall back on an internal pseudorandom generator initialized by a small amount of entropy. Target directory target directory The cp, install, ln, and mv commands normally treat the last operand specially when it is a directory or a symbolic link to a directory. For example, ‘cp source dest’ is equivalent to ‘cp source dest/source’ if dest is a directory. Sometimes this behavior is not exactly what is wanted, so these commands support the following options to allow more fine-grained control: -T’‘--no-target-directory –no-target-directory target directory destination directoryDo not treat the last operand specially when it is a directory or asymbolic link to a directory. This can help avoid race conditions inprograms that operate in a shared area. For example, when the command‘mv /tmp/source /tmp/dest’ succeeds, there is no guarantee that/tmp/source was renamed to /tmp/dest: it could have beenrenamed to /tmp/dest/source instead, if some other processcreated /tmp/dest as a directory. However, if mv-T /tmp/source /tmp/dest succeeds, there is noquestion that /tmp/source was renamed to /tmp/dest.In the opposite situation, where you want the last operand to betreated as a directory and want a diagnostic otherwise, you can usethe () option. -t directory’‘--target-directory=directory –target-directory target directory destination directoryUse directory as the directory component of each destinationfile name.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 xargsprogram is designed to work well with this convention.The commands in the mv-family are unusual in that they takea variable number of arguments with a special case at the end(namely, the target directory). This makes it nontrivial to perform someoperations, e.g., “move all files from here to ../d/”, becausemv * ../d/ might exhaust the argument space, and 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 –target-directory () option allows the cp,install, ln, and mv programs to be usedconveniently with xargs. For example, you can move the filesfrom the current directory to a sibling directory, d like this: ls | xargs mv -t ../d -- However, this doesn't move files whose names begin with ‘.’.If you use the gnu find program, you can move thosefiles too, with this command: find . -mindepth 1 -maxdepth 1 \ | xargs mv -t ../d But both of the above approaches fail if there are no files in thecurrent directory, or if any file has a name containing a blank orsome other special characters.The following example removes those limitations and requires bothgnu find and gnu xargs: find . -mindepth 1 -maxdepth 1 -print0 \ | xargs --null --no-run-if-empty \ mv -t ../d The () and () options cannot be combined. Trailing slashes trailing slashes Some gnu programs (at least cp and mv) allow you to remove any trailing slashes from each source argument before operating on it. The –strip-trailing-slashes option enables this behavior. This is useful when a source argument may have a trailing slash and specify a symbolic link to a directory. This scenario is in fact rather common because some shells can automatically append a trailing slash when performing file name completion on such symbolic links. Without this option, 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 directory and not the symbolic link. Although it may seem surprising that such behavior be the default, it is required by POSIX and is consistent with other parts of that standard. Traversing symlinks symbolic link to directory, controlling traversal of The following options modify how chown and chgrp traverse a hierarchy when the () option is also specified. If more than one of the following options is specified, only the final one takes effect. These options specify whether processing a symbolic link to a directory entails operating on just the symbolic link or on all files in the hierarchy rooted at that directory. These options are independent of and (), which control whether to modify a symlink or its referent. -H -H symbolic link to directory, traverse each that is specified on the command lineIf () is specified anda command line argument is a symbolic link to a directory, traverse it. -L -L symbolic link to directory, traverse each that is encounteredIn a recursive traversal, traverse every symbolic link to a directorythat is encountered. -P -P symbolic link to directory, never traverseDo not traverse any symbolic links.This is the default if none of , ,or is specified. Treating / specially Certain commands can operate destructively on entire hierarchies. For example, if a user with appropriate privileges mistakenly runs ‘rm -rf / tmp/junk’, that may remove all files on the entire system. Since there are so few legitimate uses for such a command, gnu rm normally declines to operate on any directory that resolves to /. If you really want to try to remove all the files on your system, you can use the option, but the default behavior, specified by the , is safer for most purposes. The commands chgrp, chmod and chown can also operate destructively on entire hierarchies, so they too support these options. Although, unlike rm, they don't actually unlink files, these commands are arguably more dangerous when operating recursively on /, since they often work much more quickly, and hence damage more files before an alert user can interrupt them. Tradition and POSIX require these commands to operate recursively on /, so they default to , but using the option makes them safer for most purposes. For convenience you can specify in an alias or in a shell function. Note that the option also ensures that chgrp and chown do not modify / even when dereferencing a symlink pointing to /. Special built-in utilities Some programs like nice can invoke other programs; for example, the command ‘nice cat file’ invokes the program cat by executing the command ‘cat file’. However, special built-in utilities like exit cannot be invoked this way. For example, the command ‘nice exit’ does not have a 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 POSIX 1003.1-2004. . : break continue eval exec exit export readonly return set shift times trap unset For example, because ‘.’, ‘:’, and ‘exec’ are special, the commands ‘nice . foo.sh’, ‘nice :’, and ‘nice exec pwd’ do not work as you might expect. Many shells extend this list. For example, Bash has several extra special built-in utilities like history, and suspend, and with Bash the command ‘nice suspend’ generates an error message instead of suspending. Standards conformance POSIXLY_CORRECT In a few cases, the gnu utilities' default behavior is incompatible with the POSIX standard. To suppress these incompatibilities, define the POSIXLY_CORRECT environment variable. Unless you are checking for POSIX conformance, you probably do not need to define POSIXLY_CORRECT. Newer versions of POSIX are occasionally incompatible with older versions. For example, older versions of POSIX required the command ‘sort +1’ to sort based on the second and succeeding fields in each input line, but starting with POSIX 1003.1-2001 the same command is required to sort the file named +1, and you must instead use the command ‘sort -k 2’ to get the field-based sort. _POSIX2_VERSION 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 POSIX, define the _POSIX2_VERSION environment variable to a value of the form yyyymm specifying the year and month the standard was adopted. Two values are currently supported for _POSIX2_VERSION: ‘199209’ stands for POSIX 1003.2-1992, and ‘200112’ stands for POSIX 1003.1-2001. For example, if you have a newer system but are running software that assumes an older version of POSIX and uses ‘sort +1’ or ‘tail +10’, you can work around any compatibility problems by setting ‘_POSIX2_VERSION=199209’ in your environment. Output of entire files output of entire files entire files, output of These commands read and write entire files, possibly transforming them in some way. cat: Concatenate and write files cat concatenate and write files copying files cat copies each file (‘-’ means standard input), or standard input if none are given, to standard output. Synopsis: cat [option] [file]… The program accepts the following options. Also see . -A’‘--show-all -A –show-allEquivalent to . -b’‘--number-nonblank -b –number-nonblankNumber all nonblank output lines, starting with 1. -e -eEquivalent to . -E’‘--show-ends -E –show-endsDisplay a ‘$’ after the end of each line. -n’‘--number -n –numberNumber all output lines, starting with 1. -s’‘--squeeze-blank -s –squeeze-blank squeezing blank linesReplace multiple adjacent blank lines with a single blank line. -t -tEquivalent to . -T’‘--show-tabs -T –show-tabsDisplay TAB characters as ‘^I’. -u -uIgnored; for POSIX compatibility. -v’‘--show-nonprinting -v –show-nonprintingDisplay control characters except for LFD and TAB using‘^’ notation and precede characters that have the high bit set with‘M-’. On systems like MS-DOS that distinguish between text and binary files, cat normally reads and writes in binary mode. However, cat reads in text mode if one of the options is used or if cat is reading from standard input and standard input is a terminal. Similarly, cat writes in text mode if one of the options is used or if standard output is a terminal. An exit status of zero indicates success, and a nonzero value indicates failure. Examples: # Output f's contents, then standard input, then g's contents. cat f - g # Copy standard input to standard output. cat tac: Concatenate and write files in reverse tac reversing files tac copies each file (‘-’ means standard input), or standard input if none are given, to standard output, reversing the records (lines by default) in each separately. Synopsis: tac [option]… [file]… Records are separated by instances of a string (newline by default). By default, this separator string is attached to the end of the record that it follows in the file. The program accepts the following options. Also see . -b’‘--before -b –beforeThe separator is attached to the beginning of the record that itprecedes in the file. -r’‘--regex -r –regexTreat the separator string as a regular expression. Users of tacon MS-DOS/MS-Windows should note that, since tac reads files inbinary mode, each line of a text file might end with a CR/LF pairinstead of the Unix-style LF. -s separator’‘--separator=separator -s –separatorUse separator as the record separator, instead of newline. An exit status of zero indicates success, and a nonzero value indicates failure. nl: Number lines and write files nl numbering lines line numbering nl writes each file (‘-’ means standard input), or standard input if none are given, to standard output, with line numbers added to some or all of the lines. Synopsis: nl [option]… [file]… logical pages, numbering on nl decomposes its input into (logical) pages; by default, the line number is reset to 1 at the top of each logical page. nl treats all of the input files as a single document; it does not reset line numbers or logical pages between files. headers, numbering body, numbering footers, numbering A logical page consists of three sections: header, body, and footer. Any of the sections can be empty. Each can be numbered in a different style from the others. The beginnings of the sections of logical pages are indicated in the input file by a line containing exactly one of these delimiter strings: \:\:\:start of header; \:\:start of body; \:start of footer. The two characters from which these strings are made can be changed from ‘\’ and ‘:’ via options (see below), but the pattern and length of each string cannot be changed. A section delimiter is replaced by an empty line on output. Any text that comes before the first section delimiter string in the input file is considered to be part of a body section, so nl treats a file that contains no section delimiters as a single body section. The program accepts the following options. Also see . -b style’‘--body-numbering=style -b –body-numberingSelect the numbering style for lines in the body section of eachlogical page. When a line is not numbered, the current line numberis not incremented, but the line number separator character is stillprepended to the line. The styles are: anumber all lines, tnumber only nonempty lines (default for body), ndo not number lines (default for header and footer), pbrenumber only lines that contain a match for the basic regularexpression bre.See See section ``Regular Expressions'' in The GNU Grep Manual. -d cd’‘--section-delimiter=cd -d –section-delimiter section delimiters of pagesSet the section delimiter characters to cd; default is‘\:’. If only c is given, the second remains ‘:’.(Remember to protect ‘\’ or other metacharacters from shellexpansion with quotes or extra backslashes.) -f style’‘--footer-numbering=style -f –footer-numberingAnalogous to . -h style’‘--header-numbering=style -h –header-numberingAnalogous to . -i number’‘--page-increment=number -i –page-incrementIncrement line numbers by number (default 1). -l number’‘--join-blank-lines=number -l –join-blank-lines empty lines, numbering blank lines, numberingConsider number (default 1) consecutive empty lines to be onelogical line for numbering, and only number the last one. Where fewerthan number consecutive empty lines occur, do not number them.An empty line is one that contains no characters, not even spacesor tabs. -n format’‘--number-format=format -n –number-formatSelect the line numbering format (default is rn): ln ln format for nlleft justified, no leading zeros; rn rn format for nlright justified, no leading zeros; rz rz format for nlright justified, leading zeros. -p’‘--no-renumber -p –no-renumberDo not reset the line number at the start of a logical page. -s string’‘--number-separator=string -s –number-separatorSeparate the line number from the text line in the output withstring (default is the TAB character). -v number’‘--starting-line-number=number -v –starting-line-numberSet the initial line number on each logical page to number (default 1). -w number’‘--number-width=number -w –number-widthUse number characters for line numbers (default 6). An exit status of zero indicates success, and a nonzero value indicates failure. od: Write files in octal or other formats od octal dump of files hex dump of files ASCII dump of files file contents, dumping unambiguously od writes an unambiguous representation of each file (‘-’ means standard input), or standard input if none are given. Synopses: od [option]… [file]… od [-abcdfilosx]… [file] [[+]offset[.][b]] od [option]… --traditional [file] [[+]offset[.][b] [[+]label[.][b]]] Each line of output consists of the offset in the input, followed by groups of data from the file. By default, od prints the offset in octal, and each group of file data is a C short int's worth of input printed as a single octal number. If offset is given, it specifies how many input bytes to skip before formatting and writing. By default, it is interpreted as an octal number, but the optional trailing decimal point causes it to be interpreted as decimal. If no decimal is specified and the offset begins with ‘0x’ or ‘0X’ it is interpreted as a hexadecimal number. If there is a trailing ‘b’, the number of bytes skipped will be offset multiplied by 512. If a command is of both the first and second forms, the second form is assumed if the last operand begins with ‘+’ or (if there are two operands) a digit. For example, in ‘od foo 10’ and ‘od +10’ the ‘10’ is an offset, whereas in ‘od 10’ the ‘10’ is a file name. The program accepts the following options. Also see . -A radix’‘--address-radix=radix -A –address-radix radix for file offsets file offset radixSelect the base in which file offsets are printed. radix canbe one of the following: ddecimal; ooctal; xhexadecimal; nnone (do not print offsets). The default is octal. -j bytes’‘--skip-bytes=bytes -j –skip-bytesSkip bytes input bytes before formatting and writing. Ifbytes begins with ‘0x’ or ‘0X’, it is interpreted inhexadecimal; otherwise, if it begins with ‘0’, in octal; otherwise,in decimal. Appending ‘b’ multiplies bytes by 512, ‘k’by 1024, and ‘m’ by 1048576. -N bytes’‘--read-bytes=bytes -N –read-bytesOutput at most bytes bytes of the input. Prefixes and suffixes onbytes are interpreted as for the option. -S n’‘--strings[=n] -S –strings string constants, outputtingInstead of the normal output, output only string constants: atleast n consecutive ASCII graphic characters,followed by a null (zero) byte.If n is omitted with , the default is 3. -t type’‘--format=type -t –formatSelect the format in which to output the file data. type is astring of one or more of the below type indicator characters. If youinclude more than one type indicator character in a single typestring, or use this option more than once, od writes one copyof 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 displayof the ASCII character representation of the printable charactersto the output line generated by the type specification. anamed character, ignoring high-order bit cASCII character or backslash escape, dsigned decimal ffloating point ooctal uunsigned decimal xhexadecimal The type a outputs things like ‘sp’ for space, ‘nl’ fornewline, and ‘nul’ for a null (zero) byte. Only the least significantseven bits of each byte is used; the high-order bit is ignored.Type c outputs‘ ’, ‘\n’, and \0, respectively. type sizeExcept for types ‘a’ and ‘c’, you can specify the numberof bytes to use in interpreting each number in the given data typeby following the type indicator character with a decimal integer.Alternately, you can specify the size of one of the C compiler'sbuilt-in data types by following the type indicator character withone of the following characters. For integers (‘d’, ‘o’,‘u’, ‘x’): Cchar Sshort Iint Llong For floating point (f): F float D double L long double -v’‘--output-duplicates -v –output-duplicatesOutput consecutive lines that are identical. By default, when two ormore consecutive output lines would be identical, od outputs onlythe first line, and puts just an asterisk on the following line toindicate the elision. -w[n]’‘--width[=n] -w –widthDump n input bytes per output line. This must be a multiple ofthe least common multiple of the sizes associated with the specifiedoutput types.If this option is not given at all, the default is 16. If n isomitted, the default is 32. The next several options are shorthands for format specifications. gnu od accepts any combination of shorthands and format specification options. These options accumulate. -a -aOutput as named characters. Equivalent to ‘-t a’. -b -bOutput as octal bytes. Equivalent to ‘-t o1’. -c -cOutput as ASCII characters or backslash escapes. Equivalent to‘-t c’. -d -dOutput as unsigned decimal two-byte units. Equivalent to ‘-t u2’. -f -fOutput as floats. Equivalent to ‘-t fF’. -i -iOutput as decimal ints. Equivalent to ‘-t dI’. -l -lOutput as decimal long ints. Equivalent to ‘-t dL’. -o -oOutput as octal two-byte units. Equivalent to . -s -sOutput as decimal two-byte units. Equivalent to . -x -xOutput as hexadecimal two-byte units. Equivalent to ‘-t x2’. --traditional –traditionalRecognize the non-option label argument that traditional odaccepted. The following syntax: od --traditional [file] [[+]offset[.][b] [[+]label[.][b]]] can be used to specify at most one file and optional argumentsspecifying an offset and a pseudo-start address, label.The label argument is interpretedjust like offset, but it specifies an initial pseudo-address. Thepseudo-addresses are displayed in parentheses following any normaladdress. An exit status of zero indicates success, and a nonzero value indicates failure. base64: Transform data into printable data. base64 base64 encoding base64 transforms data read from a file, or standard input, into (or from) base64 encoded form. The base64 encoded form uses printable ASCII characters to represent binary data, see RFC 3548. Synopses: base64 [option]… [file] base64 --decode [option]… [file] The base64 encoding expands data to roughly 133% of the original. The program accepts the following options. Also see . -w COLS’‘--wrap=COLS -w –wrap wrap data column to wrap data afterDuring encoding, wrap lines after COLS characters. This must bea positive number.The default is to wrap after 76 characters. Use the value 0 todisable line wrapping altogether. -d’‘--decode -d –decode Decode base64 data Base64 decodingChange the mode of operation, from the default of encoding data, todecoding data. Input is expected to be base64 encoded data, and theoutput will be the original data. -i’‘--ignore-garbage -i –ignore-garbage Ignore garbage in base64 streamWhen decoding, newlines are always accepted.During decoding, ignore unrecognized bytes,to permit distorted data to be decoded. An exit status of zero indicates success, and a nonzero value indicates failure. Formatting file contents formatting file contents These commands reformat the contents of files. fmt: Reformat paragraph text fmt reformatting paragraph text paragraphs, reformatting text, reformatting fmt fills and joins lines to produce output lines of (at most) a given number of characters (75 by default). Synopsis: fmt [option]… [file]… fmt reads from the specified file arguments (or standard input if none are given), and writes to standard output. By default, blank lines, spaces between words, and indentation are preserved in the output; successive input lines with different indentation are not joined; tabs are expanded on input and introduced on output. line-breaking sentences and line-breaking Knuth, Donald E. Plass, Michael F. fmt prefers breaking lines at the end of a sentence, and tries to avoid line breaks after the first word of a sentence or before the last word of a sentence. A sentence break is defined as either the end of a paragraph or a word ending in any of ‘.?!’, followed by two spaces or end of line, ignoring any intervening parentheses or quotes. Like &tex;, fmt reads entire “paragraphs” before choosing line breaks; the algorithm is a variant of that given by Donald E. Knuth and Michael F. Plass in “Breaking Paragraphs Into Lines”, Software—Practice & Experience 11, 11 (November 1981), 1119–1184. The program accepts the following options. Also see . -c’‘--crown-margin -c –crown-margin crown marginCrown margin mode: preserve the indentation of the first twolines within a paragraph, and align the left margin of each subsequentline with that of the second line. -t’‘--tagged-paragraph -t –tagged-paragraph tagged paragraphsTagged paragraph mode: like crown margin mode, except that ifindentation of the first line of a paragraph is the same as theindentation of the second, the first line is treated as a one-lineparagraph. -s’‘--split-only -s –split-onlySplit lines only. Do not join short lines to form longer ones. Thisprevents sample lines of code, and other such “formatted” text frombeing unduly combined. -u’‘--uniform-spacing -u –uniform-spacingUniform spacing. Reduce spacing between words to one space, and spacingbetween sentences to two spaces. -width’‘-w width’‘--width=width -width -w –widthFill output lines up to width characters (default 75). fmtinitially tries to make lines about 7% shorter than this, to give itroom to balance line lengths. -p prefix’‘--prefix=prefixOnly lines beginning with prefix (possibly preceded by whitespace)are subject to formatting. The prefix and any preceding whitespace arestripped for the formatting and then re-attached to each formatted outputline. One use is to format certain kinds of program comments, whileleaving the code unchanged. An exit status of zero indicates success, and a nonzero value indicates failure. pr: Paginate or columnate files for printing pr printing, preparing files for multicolumn output, generating merging files in parallel pr writes each file (‘-’ means standard input), or standard input if none are given, to standard output, paginating and optionally outputting in multicolumn format; optionally merges all files, printing all in parallel, one per column. Synopsis: pr [option]… [file]… LC_MESSAGES By default, a 5-line header is printed at each page: two blank lines; a line with the date, the file name, and the page count; and two more blank lines. A footer of five blank lines is also printed. With the option, a 3-line header is printed: the leading two blank lines are omitted; no footer is used. The default page_length in both cases is 66 lines. The default number of text lines changes from 56 (without ) to 63 (with ). The text line of the header takes the form ‘date string page’, with spaces inserted around string so that the line takes up the full page_width. Here, date is the date (see the or option for details), string is the centered header string, and page identifies the page number. The LC_MESSAGES locale category affects the spelling of page; in the default C locale, it is ‘Page number’ where number is the decimal page number. Form feeds in the input cause page breaks in the output. Multiple form feeds produce empty pages. Columns are of equal width, separated by an optional string (default is ‘space’). For multicolumn output, lines will always be truncated to page_width (default 72), unless you use the option. For single column output no line truncation occurs by default. Use option to truncate lines in that case. The following changes were made in version 1.22i and apply to later versions of pr: - Brian Some small letter options (, ) have beenredefined for better POSIX compliance. The output of some furthercases has been adapted to other Unix systems. These changes are notcompatible with earlier versions of the program. Some new capital letter options (, , )have been introduced to turn off unexpected interferences of small letteroptions. The option and the second argument last_pageof ‘+FIRST_PAGE’ offer more flexibility. The detailed handling ofform feeds set in the input files requires the option. Capital letter options override small letter ones. Some of the option-arguments (compare , ,, ) cannot be specified as separate arguments from thepreceding option letter (already stated in the POSIX specification). The program accepts the following options. Also see . +first_page[:last_page]’‘--pages=first_page[:last_page] +page_range –pages=page_rangeBegin printing with page first_page and stop with last_page.Missing ‘:last_page’ implies end of file. While estimatingthe number of skipped pages each form feed in the input file resultsin a new page. Page counting with and without ‘+first_page’is identical. By default, counting starts with the first page of inputfile (not first page printed). Line numbering may be altered by option. -column’‘--columns=column -column –columns down columnsWith each single file, produce column columns of output(default is 1) and print columns down, unless is used. Thecolumn width is automatically decreased as column increases; unlessyou use the option to increase page_width as well.This option might well cause some lines to be truncated. The number oflines in the columns on each page are balanced. The options and are on for multiple text-column output. Together with option column alignment and line truncation is turned off.Lines of full length are joined in a free field format and option may set field separators. may not be usedwith option. -a’‘--across -a –across across columnsWith each single file, print columns across rather than down. The option must be given with column greater than one.If a line is too long to fit in a column, it is truncated. -c’‘--show-control-chars -c –show-control-charsPrint control characters using hat notation (e.g., ‘^G’); printother nonprinting characters in octal backslash notation. By default,nonprinting characters are not changed. -d’‘--double-space -d –double-space double spacingDouble space the output. -D format’‘--date-format=format time formats formatting timesFormat header dates using format, using the same conventions asfor the command ‘date +format’; See .Except for directives, which start with‘%’, characters in format are printed unchanged. You can usethis option to specify an arbitrary string in place of the header date,e.g., . POSIXLY_CORRECT LC_TIMENormally the dateformat defaults to ‘%Y-%m-%d %H:%M’ (for example, ‘2001-12-0423:59’); but if the POSIXLY_CORRECT environment variable is setand the LC_TIME locale category specifies the POSIXlocale, the default is ‘%b %e %H:%M %Y’ (for example,‘Dec 4 23:59 2001’. TZTime stamps are listed according to the time zone rules specified bythe TZ environment variable, or by the system default rules ifTZ is not set. See See section ``Specifying the Time Zonewith @env{TZ}'' in The GNU C Library. -e[in-tabchar[in-tabwidth]]’‘--expand-tabs[=in-tabchar[in-tabwidth]] -e –expand-tabs input tabsExpand tabs to spaces on input. Optional argument in-tabchar isthe input tab character (default is the TAB character). Second optionalargument in-tabwidth is the input tab character's width (defaultis 8). -f’‘-F’‘--form-feed -F -f –form-feedUse a form feed instead of newlines to separate output pages. The defaultpage length of 66 lines is not altered. But the number of lines of textper page changes from default 56 to 63 lines. -h HEADER’‘--header=HEADER -h –headerReplace the file name in the header with the centered string header.When using the shell, header should be quoted and should beseparated from by a space. -i[out-tabchar[out-tabwidth]]’‘--output-tabs[=out-tabchar[out-tabwidth]] -i –output-tabs output tabsReplace spaces with tabs on output. Optional argument out-tabcharis the output tab character (default is the TAB character). Second optionalargument out-tabwidth is the output tab character's width (defaultis 8). -J’‘--join-lines -J –join-linesMerge lines of full length. Used together with the column options, or . Turns off line truncation;no column alignment used; may be used with. has been introduced(together with and )to disentangle the old (POSIX-compliant) options and along with the three column options. -l page_length’‘--length=page_length -l –lengthSet the page length to page_length (default 66) lines, includingthe lines of the header [and the footer]. If page_length is lessthan or equal to 10 (or <= 3 with ), the header and footer areomitted, and all form feeds set in input files are eliminated, as ifthe option had been given. -m’‘--merge -m –mergeMerge and print all files in parallel, one in each column. If aline is too long to fit in a column, it is truncated, unless the option is used. may be used.Empty pages insome files (form feeds set) produce empty columns, still markedby string. The result is a continuous line numbering and columnmarking throughout the whole merged file. Completely empty merged pagesshow no separators or line numbers. The default header becomes‘date page’ with spaces inserted in the middle; thismay be used with the or option to fill upthe middle blank part. -n[number-separator[digits]]’‘--number-lines[=number-separator[digits]] -n –number-linesProvide digits digit line numbering (default for digits is5). With multicolumn output the number occupies the first digitscolumn positions of each text column or only each line of output. With single column output the number precedes each line just as does. Default counting of the line numbers starts with thefirst line of the input file (not the first line printed, compare the option and option).Optional argument number-separator is the character appended tothe line number to separate it from the text followed. The defaultseparator is the TAB character. In a strict sense a TAB is alwaysprinted with single column output only. The TAB-width varieswith the TAB-position, e.g., with the left margin specifiedby option. With multicolumn output priority is given to‘equal width of output columns’ (a POSIX specification).The TAB-width is fixed to the value of the first column and doesnot change with different values of left margin. That means afixed number of spaces is always printed in the place of thenumber-separator tab. The tabification depends upon the outputposition. -N line_number’‘--first-line-number=line_number -N –first-line-numberStart line counting with the number line_number at first line offirst page printed (in most cases not the first line of the input file). -o margin’‘--indent=margin -o –indent indenting lines left marginIndent each line with a margin margin spaces wide (default is zero).The total page width is the size of the margin plus the page_widthset with the option. A limited overflow may occur withnumbered single column output (compare option). -r’‘--no-file-warnings -r –no-file-warningsDo not print a warning message when an argument file cannot beopened. (The exit status will still be nonzero, however.) -s[char]’‘--separator[=char] -s –separatorSeparate columns by a single character char. The default forchar is the TAB character without and ‘nocharacter’ with . Without the default separator‘space’ is set. turns off line truncation of allthree column options (||) unless is set. This is a POSIX-compliant formulation. -Sstring’‘--sep-string[=string] -S –sep-stringUse string to separate output columns. The option doesn'taffect the option, unlike the option which does. Itdoes not affect line truncation or column alignment.Without , and with , pr uses the default outputseparator, TAB.Without or , pr uses a ‘space’(same as ). with no‘=string’ is equivalent to . -t’‘--omit-header -t –omit-headerDo not print the usual header [and footer] on each page, and do not fillout the bottom of pages (with blank lines or a form feed). No pagestructure is produced, but form feeds set in the input files are retained.The predefined pagination is not changed. or may beuseful together with other options; e.g.: , expand TAB charactersin the input file to 4 spaces but don't make any other changes. Use of overrides . -T’‘--omit-pagination -T –omit-paginationDo not print header [and footer]. In addition eliminate all form feedsset in the input files. -v’‘--show-nonprinting -v –show-nonprintingPrint nonprinting characters in octal backslash notation. -w page_width’‘--width=page_width -w –widthSet page width to page_width characters for multiple text-columnoutput only (default for page_width is 72). turnsoff the default page width and any line truncation and column alignment.Lines of full length are merged, regardless of the column optionsset. No page_width setting is possible with single column output.A POSIX-compliant formulation. -W page_width’‘--page_width=page_width -W –page_widthSet the page width to page_width characters. That's valid with andwithout a column option. Text lines are truncated, unless is used. Together with one of the three column options(, or ) columnalignment is always used. The separator options or don't affect the option. Default is 72 characters. Without and without any of the column options NO linetruncation is used (defined to keep downward compatibility and to meetmost frequent tasks). That's equivalent to . The headerline is never truncated. An exit status of zero indicates success, and a nonzero value indicates failure. fold: Wrap input lines to fit in specified width fold wrapping long input lines folding long input lines fold writes each file ( means standard input), or standard input if none are given, to standard output, breaking long lines. Synopsis: fold [option]… [file]… By default, fold breaks lines wider than 80 columns. The output is split into as many lines as necessary. screen columns fold counts screen columns by default; thus, a tab may count more than one column, backspace decreases the column count, and carriage return sets the column to zero. The program accepts the following options. Also see . -b’‘--bytes -b –bytesCount bytes rather than columns, so that tabs, backspaces, and carriagereturns are each counted as taking up one column, just like othercharacters. -s’‘--spaces -s –spacesBreak at word boundaries: the line is broken after the last blank beforethe maximum line length. If the line contains no such blanks, the lineis broken at the maximum line length as usual. -w width’‘--width=width -w –widthUse a maximum line length of width columns instead of 80.For compatibility fold supports an obsolete option syntax. New scripts should use instead. An exit status of zero indicates success, and a nonzero value indicates failure. Output of parts of files output of parts of files parts of files, output of These commands output pieces of the input. head: Output the first part of files head initial part of files, outputting first part of files, outputting head prints the first part (10 lines by default) of each file; it reads from standard input if no files are given or when given a file of . Synopsis: head [option]… [file]… If more than one file is specified, head prints a one-line header consisting of: ==> file name <== before the output for each file. The program accepts the following options. Also see . -c n’‘--bytes=n -c –bytesPrint the first n bytes, instead of initial lines. Appending‘b’ multiplies n by 512, ‘k’ by 1024, and ‘m’by 1048576.However, if n starts with a ‘-’,print all but the last n bytes of each file. -n n’‘--lines=n -n –linesOutput the first n lines.However, if n starts with a ‘-’,print all but the last n lines of each file. -q’‘--quiet’‘--silent -q –quiet –silentNever print file name headers. -v’‘--verbose -v –verboseAlways print file name headers. For compatibility head also supports an obsolete option syntax , which is recognized only if it is specified first. count is a decimal number optionally followed by a size letter (‘b’, ‘k’, ‘m’) as in , or ‘l’ to mean count by lines, or other option letters (‘cqv’). Scripts intended for standard hosts should use or instead. If your script must also run on hosts that support only the obsolete syntax, it is usually simpler to avoid head, e.g., by using ‘sed 5q’ instead of ‘head -5’. An exit status of zero indicates success, and a nonzero value indicates failure. tail: Output the last part of files tail last part of files, outputting tail prints the last part (10 lines by default) of each file; it reads from standard input if no files are given or when given a file of ‘-’. Synopsis: tail [option]… [file]… If more than one file is specified, tail prints a one-line header consisting of: ==> file name <== before the output for each file. BSD tail gnu tail can output any amount of data (some other versions of tail cannot). It also has no option (print in reverse), since reversing a file is really a different job from printing the end of a file; BSD tail (which is the one with ) 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 gnu tac command. If any option-argument is a number n starting with a ‘+’, tail begins printing with the nth item from the start of each file, instead of from the end. The program accepts the following options. Also see . -c bytes’‘--bytes=bytes -c –bytesOutput the last bytes bytes, instead of final lines. Appending‘b’ multiplies bytes by 512, ‘k’ by 1024, and ‘m’by 1048576. -f’‘--follow[=how] -f –follow growing files name follow option descriptor follow optionLoop forever trying to read more characters at the end of the file,presumably because the file is growing.If more than one file is given, tail prints a header whenever itgets output from a different file, to indicate which file that output isfrom.There are two ways to specify how you'd like to track files with this option,but that difference is noticeable only when a followed file is removed orrenamed.If you'd like to continue to track the end of a growing file even afterit has been unlinked, use . This is the defaultbehavior, but it is not useful if you're tracking a log file that may berotated (removed or renamed, then reopened). In that case, use to track the named file by reopening it periodicallyto see if it has been removed and recreated by some other program.No matter which method you use, if the tracked file is determined to haveshrunk, tail prints a message saying the file has been truncatedand resumes tracking the end of the file from the newly-determined endpoint.When a file is removed, tail's behavior depends on whether it isfollowing the name or the descriptor. When following by name, tail candetect that a file has been removed and gives a message to that effect,and if has been specified it will continue checkingperiodically to see if the file reappears.When following a descriptor, tail does not detect that the file hasbeen unlinked or renamed and issues no message; even though the filemay no longer be accessible via its original name, it may still begrowing.The option values ‘descriptor’ and ‘name’ may be specified onlywith the long form of the option, not with . POSIXLY_CORRECTIf POSIXLY_CORRECT is set, the option is ignored ifno file operand is specified and standard input is a FIFO or a pipe. -F -FThis option is the same as . That is, tailwill attempt to reopen a file when it is removed. Should this fail, tailwill keep trying until it becomes accessible again. --retry –retryThis option is useful mainly when following by name (i.e., with).Without this option, when tail encounters a file that doesn'texist or is otherwise inaccessible, it reports that fact andnever checks it again. --sleep-interval=number –sleep-intervalChange 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 haschanged size.Historical implementations of tail have required thatnumber be an integer. However, GNU tail acceptsan arbitrary floating point number (using a period before anyfractional digits). --pid=pid –pidWhen following by name or by descriptor, you may specify the process ID,pid, of the sole writer of all file arguments. Then, shortlyafter that process terminates, tail will also terminate. This willwork properly only if the writer and the tailing process are running onthe same machine. For example, to save the output of a build in a fileand to watch the file grow, if you invoke make and taillike this then the tail process will stop when your build completes.Without this option, you would have had to kill the tail -fprocess yourself. $ make >& makerr & tail --pid=$! -f makerr If you specify a pid that is not in use or that does not correspondto the process that is writing to the tailed files, then tailmay terminate long before any files stop growing or it may notterminate until long after the real writer has terminated.Note that cannot be supported on some systems; tailwill print a warning if this is the case. --max-unchanged-stats=n –max-unchanged-statsWhen tailing a file by name, if there have been n (defaultn=5) consecutiveiterations for which the file has not changed, thenopen/fstat the file to determine if that file name isstill associated with the same device/inode-number pair as before.When following a log file that is rotated, this is approximately thenumber of seconds between when tail prints the last pre-rotation linesand when it prints the lines that have accumulated in the new log file.This option is meaningful only when following by name. -n n’‘--lines=n -n –linesOutput the last n lines. -q’‘--quiet’‘--silent -q –quiet –silentNever print file name headers. -v’‘--verbose -v –verboseAlways print file name headers. For compatibility tail also supports an obsolete usage ‘tail -[count][bcl][f] [file]’, which is recognized only if it does not conflict with the usage described above. This obsolete form uses exactly one option and at most one file. In the option, count is an optional decimal number optionally followed by a size letter (‘b’, ‘c’, ‘l’) to mean count by 512-byte blocks, bytes, or lines, optionally followed by ‘f’ which has the same meaning as . _POSIX2_VERSION On older systems, the leading ‘-’ can be replaced by ‘+’ in the obsolete option syntax with the same meaning as in counts, and obsolete usage overrides normal usage when the two conflict. This obsolete behavior can be enabled or disabled with the _POSIX2_VERSION environment variable (see ). Scripts intended for use on standard hosts should avoid obsolete syntax and should use , , and/or instead. If your script must also run on hosts that support only the obsolete syntax, you can often rewrite it to avoid problematic usages, e.g., by using ‘sed -n '$p'’ rather than ‘tail -1’. If that's not possible, the script can use a test like ‘if tail -c +1 </dev/null >/dev/null 2>&1; then …’ 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 POSIX version. For example, avoid ‘tail - main.c’, since it might be interpreted as either ‘tail main.c’ or as ‘tail -- - main.c’; avoid ‘tail -c 4’, since it might mean either ‘tail -c4’ or ‘tail -c 10 4’; and avoid ‘tail +4’, since it might mean either ‘tail ./+4’ or ‘tail -n +4’. An exit status of zero indicates success, and a nonzero value indicates failure. split: Split a file into fixed-size pieces split splitting a file into pieces pieces, splitting a file into split creates output files containing consecutive sections of input (standard input if none is given or input is ‘-’). Synopsis: split [option] [input [prefix]] By default, split puts 1000 lines of input (or whatever is left over for the last section), into each output file. output file name prefix The output files' names consist of prefix (‘x’ by default) followed by a group of characters (‘aa’, ‘ab’, … by default), such that concatenating the output files in traditional sorted order by file name produces the original input file. If the output file names are exhausted, split reports an error without deleting the output files that it did create. The program accepts the following options. Also see . -a length’‘--suffix-length=length -a –suffix-lengthUse suffixes of length length. The default length is 2. -l lines’‘--lines=lines -l –linesPut lines lines of input into each output file.For compatibility split also supports an obsoleteoption syntax . New scripts should use instead. -b bytes’‘--bytes=bytes -b –bytesPut the first bytes bytes of input into each output file.Appending ‘b’ multiplies bytes by 512, ‘k’ by 1024, and‘m’ by 1048576. -C bytes’‘--line-bytes=bytes -C –line-bytesPut into each output file as many complete lines of input aspossible without exceeding bytes bytes. For lines longer thanbytes bytes, put bytes bytes into each output file untilless than bytes bytes of the line are left, then continuenormally. bytes has the same format as for the option. -d’‘--numeric-suffixes -d –numeric-suffixesUse digits in suffixes rather than lower-case letters. --verbose –verboseWrite a diagnostic to standard error just before each output file is opened. An exit status of zero indicates success, and a nonzero value indicates failure. csplit: Split a file into context-determined pieces csplit context splitting splitting a file into pieces by context csplit creates zero or more output files containing sections of input (standard input if input is ‘-’). Synopsis: csplit [option]… input pattern The contents of the output files are determined by the pattern arguments, as detailed below. An error occurs if a pattern argument refers to a nonexistent line of the input file (e.g., if no remaining line matches a given regular expression). After every pattern has been matched, any remaining input is copied into one last output file. By default, csplit prints the number of bytes written to each output file after it has been created. The types of pattern arguments are: nCreate an output file containing the input up to but not including linen (a positive integer). If followed by a repeat count, alsocreate an output file containing the next n lines of the inputfile once for each repeat. /regexp/[offset]Create an output file containing the current line up to (but notincluding) the next line of the input file that contains a match forregexp. The optional offset is an integer.If it is given, the input up to (but not including) thematching line plus or minus offset is put into the output file,and the line after that begins the next section of input. %regexp%[offset]Like the previous type, except that it does not create an outputfile, so that section of the input file is effectively ignored. {repeat-count}Repeat the previous pattern repeat-count additionaltimes. The repeat-count can either be a positive integer or anasterisk, meaning repeat as many times as necessary until the input isexhausted. The output files' names consist of a prefix (‘xx’ by default) followed by a suffix. By default, the suffix is an ascending sequence of two-digit decimal numbers from ‘00’ to ‘99’. In any case, concatenating the output files in sorted order by file name produces the original input file. By default, if csplit encounters an error or receives a hangup, interrupt, quit, or terminate signal, it removes any output files that it has created so far before it exits. The program accepts the following options. Also see . -f prefix’‘--prefix=prefix -f –prefix output file name prefixUse prefix as the output file name prefix. -b suffix’‘--suffix=suffix -b –suffix output file name suffixUse suffix as the output file name suffix. When this option isspecified, the suffix string must include exactly oneprintf(3)-style conversion specification, possibly includingformat specification flags, a field width, a precision specifications,or all of these kinds of modifiers. The format letter must convert abinary integer argument to readable form; thus, only ‘d’, ‘i’,‘u’, ‘o’, ‘x’, and ‘X’ conversions are allowed. Theentire suffix is given (with the current output file number) tosprintf(3) to form the file name suffixes for each of theindividual output files in turn. If this option is used, the option is ignored. -n digits’‘--digits=digits -n –digitsUse output file names containing numbers that are digits digitslong instead of the default 2. -k’‘--keep-files -k –keep-filesDo not remove output files when errors are encountered. -z’‘--elide-empty-files -z –elide-empty-filesSuppress the generation of zero-length output files. (In cases wherethe section delimiters of the input file are supposed to mark the firstlines of each of the sections, the first output file will generally be azero-length file unless you use this option.) The output file sequencenumbers always run consecutively starting from 0, even when this optionis specified. -s’‘-q’‘--silent’‘--quiet -s -q –silent –quietDo not print counts of output file sizes. An exit status of zero indicates success, and a nonzero value indicates failure. Summarizing files summarizing files These commands generate just a few numbers representing entire contents of files. wc: Print newline, word, and byte counts wc byte count character count word count line count wc counts the number of bytes, characters, whitespace-separated words, and newlines in each given file, or standard input if none are given or for a file of ‘-’. Synopsis: wc [option]… [file]… total counts wc prints one line of counts for each file, and if the file was given as an argument, it prints the file name following the counts. If more than one file is given, wc prints a final line containing the cumulative counts, with the file name total. The counts are printed in this order: newlines, words, characters, bytes, maximum line length. 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 GNU extension, if only one count is printed, it is guaranteed to be printed without leading spaces. By default, wc prints three counts: the newline, words, and byte counts. Options can specify that only certain counts be printed. Options do not undo others previously given, so wc --bytes --words prints both the byte counts and the word counts. With the option, wc prints the length of the longest line per file, and if there is more than one file it prints the maximum (not the sum) of those lengths. The program accepts the following options. Also see . -c’‘--bytes -c –bytesPrint only the byte counts. -m’‘--chars -m –charsPrint only the character counts. -w’‘--words -w –wordsPrint only the word counts. -l’‘--lines -l –linesPrint only the newline counts. -L’‘--max-line-length -L –max-line-lengthPrint only the maximum line lengths. --files0-from=FILE –files0-from=FILE including files from duRather than processing files named on the command line, process thosenamed in file FILE; each name is terminated by a null byte.This is useful whenthe list of file names is so long that it may exceed a command linelength limitation.In such cases, running wc via xargs is undesirablebecause it splits the list into pieces and makes wc print atotal for each sublist rather than for the entire list.One way to produce a list of null-byte-terminated file names is with gnufind, using its predicate. For example, to findthe length of the longest line in any .c or .h file in thecurrent hierarchy, do this: find . -name '*.[ch]' -print0 | wc -L --files0-from=- | tail -n1 Do not specify any FILE on the command line when using this option. An exit status of zero indicates success, and a nonzero value indicates failure. sum: Print checksum and block counts sum 16-bit checksum checksum, 16-bit sum computes a 16-bit checksum for each given file, or standard input if none are given or for a file of ‘-’. Synopsis: sum [option]… [file]… sum prints the checksum for each file followed by the number of blocks in the file (rounded up). If more than one file is given, file names are also printed (by default). (With the option, corresponding file names are printed when there is at least one file argument.) By default, gnu sum computes checksums using an algorithm compatible with BSD sum and prints file sizes in units of 1024-byte blocks. The program accepts the following options. Also see . -r -r BSD sumUse the default (BSD compatible) algorithm. This option is included forcompatibility with the System V sum. Unless was alsogiven, it has no effect. -s’‘--sysv -s –sysv System V sumCompute checksums using an algorithm compatible with System Vsum's default, and print file sizes in units of 512-byte blocks. sum is provided for compatibility; the cksum program (see next section) is preferable in new applications. An exit status of zero indicates success, and a nonzero value indicates failure. cksum: Print CRC checksum and byte counts cksum cyclic redundancy check CRC checksum cksum computes a cyclic redundancy check (CRC) checksum for each given file, or standard input if none are given or for a file of ‘-’. Synopsis: cksum [option]… [file]… cksum prints the CRC checksum for each file along with the number of bytes in the file, and the file name unless no arguments were given. cksum is typically used to ensure that files transferred by unreliable means (e.g., netnews) have not been corrupted, by comparing the cksum output for the received files with the cksum output for the original files (typically given in the distribution). The CRC algorithm is specified by the POSIX standard. It is not compatible with the BSD or System V sum algorithms (see the previous section); it is more robust. The only options are and . See . An exit status of zero indicates success, and a nonzero value indicates failure. md5sum: Print or check MD5 digests md5sum MD5 128-bit checksum checksum, 128-bit fingerprint, 128-bit message-digest, 128-bit md5sum computes a 128-bit checksum (or fingerprint or message-digest) for each specified file. Note: The MD5 digest is more reliable than a simple CRC (provided by the cksum command) for detecting accidental file corruption, as the chances of accidentally having two files with identical MD5 are vanishingly small. However, it should not be considered truly secure against malicious tampering: although finding a file with a given MD5 fingerprint, or modifying a file so as to retain its MD5 are considered infeasible at the moment, it is known how to produce different files with identical MD5 (a “collision”), something which can be a security issue in certain contexts. For more secure hashes, consider using SHA-1 or SHA-2. See , and . If a file is specified as ‘-’ or if no files are given md5sum computes the checksum for the standard input. md5sum can also determine whether a file and checksum are consistent. Synopsis: md5sum [option]… [file]… For each file, ‘md5sum’ outputs the MD5 checksum, a flag indicating a binary or text input file, and the file name. If 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 unambiguous even in the presence of arbitrary file names. If file is omitted or specified as ‘-’, standard input is read. The program accepts the following options. Also see . -b’‘--binary -b –binary binary input filesTreat each input file as binary, by reading it in binary mode andoutputting a ‘*’ flag. This is the inverse of .On systems like GNU that do not distinguish between binaryand text files, this option merely flags each input file as binary:the MD5 checksum is unaffected. This option is the default on systemslike MS-DOS that distinguish between binary and text files, exceptfor reading standard input when standard input is a terminal. -c’‘--checkRead file names and checksum information (not data) from eachfile (or from stdin if no file was specified) and reportwhether the checksums match the contents of the named files.The input to this mode of md5sum is usually the output ofa prior, checksum-generating run of ‘md5sum’.Each valid line of input consists of an MD5 checksum, a binary/textflag, and then a file name.Binary files are marked with ‘*’, text with ‘ ’.For each such line, md5sum reads the named file and computes itsMD5 checksum. Then, if the computed message digest does not match theone on the line with the file name, the file is noted as havingfailed the test. Otherwise, the file passes the test.By default, for each valid line, one line is written to standardoutput indicating whether the named file passed the test.After all checks have been performed, if there were any failures,a warning is issued to standard error.Use the option to inhibit that output.If any listed file cannot be opened or read, if any valid line hasan MD5 checksum inconsistent with the associated file, or if no validline is found, md5sum exits with nonzero status. Otherwise,it exits successfully. --status –status verifying MD5 checksumsThis option is useful only when verifying checksums.When verifying checksums, don't generate the default one-line-per-filediagnostic and don't output the warning summarizing any failures.Failures to open or read a file still evoke individual diagnostics tostandard error.If all listed files are readable and are consistent with the associatedMD5 checksums, exit successfully. Otherwise exit with a status codeindicating there was a failure. -t’‘--text -t –text text input filesTreat each input file as text, by reading it in text mode andoutputting a ‘ ’ flag. This is the inverse of .This option is the default on systems like GNU that do notdistinguish between binary and text files. On other systems, it isthe default for reading standard input when standard input is aterminal. -w’‘--warn -w –warn verifying MD5 checksumsWhen verifying checksums, warn about improperly formatted MD5 checksum lines.This option is useful only if all but a few lines in the checked inputare valid. An exit status of zero indicates success, and a nonzero value indicates failure. sha1sum: Print or check SHA-1 digests sha1sum SHA-1 160-bit checksum checksum, 160-bit fingerprint, 160-bit message-digest, 160-bit sha1sum computes a 160-bit checksum for each specified file. The usage and options of this command are precisely the same as for md5sum. See . Note: The SHA-1 digest is more secure than MD5, and no collisions of it are known (different files having the same fingerprint). However, it is known that they can be produced with considerable, but not unreasonable, resources. For this reason, it is generally considered that SHA-1 should be gradually phased out in favor of the more secure SHA-2 hash algorithms. See . sha2 utilities: Print or check SHA-2 digests sha224sum sha256sum sha384sum sha512sum SHA-2 224-bit checksum 256-bit checksum 384-bit checksum 512-bit checksum checksum, 224-bit checksum, 256-bit checksum, 384-bit checksum, 512-bit fingerprint, 224-bit fingerprint, 256-bit fingerprint, 384-bit fingerprint, 512-bit message-digest, 224-bit message-digest, 256-bit message-digest, 384-bit message-digest, 512-bit The commands sha224sum, sha256sum, sha384sum and sha512sum compute checksums of various lengths (respectively 224, 256, 384 and 512 bits), collectively known as the SHA-2 hashes. The usage and options of these commands are precisely the same as for md5sum. See . Note: The SHA384 and SHA512 digests are considerably slower to compute, especially on 32-bit computers, than SHA224 or SHA256. Operating on sorted files operating on sorted files sorted files, operations on These commands work with (or produce) sorted files. sort: Sort text files sort sorting files sort sorts, merges, or compares all the lines from the given files, or standard input if none are given or for a file of ‘-’. By default, sort writes the results to standard output. Synopsis: sort [option]… [file]… sort has three modes of operation: sort (the default), merge, and check for sortedness. The following options change the operation mode: -c’‘--check’‘--check=diagnose-first -c –check checking for sortednessCheck whether the given file is already sorted: if it is not allsorted, print a diagnostic containing the first out-of-order line andexit with a status of 1.Otherwise, exit successfully.At most one input file can be given. -C’‘--check=quiet’‘--check=silent -c –check checking for sortednessExit successfully if the given file is already sorted, andexit with status 1 otherwise.At most one input file can be given.This is like , except it does not print a diagnostic. -m’‘--merge -m –merge merging sorted filesMerge the given files by sorting them as a group. Each input file mustalways be individually sorted. It always works to sort instead ofmerge; merging is provided because it is faster, in the case where itworks. sort stability sort's last-resort comparison A pair of lines is compared as follows: sort compares each pair of fields, in the order specified on the command line, according to the associated ordering options, until a difference is found or no fields are left. If no key fields are specified, sort uses a default key of the entire line. Finally, as a last resort when all keys compare equal, sort compares entire lines as if no ordering options other than () were specified. The () option disables this last-resort comparison so that lines in which all fields compare equal are left in their original relative order. The () option also disables the last-resort comparison. LC_ALL LC_COLLATE Unless otherwise specified, all comparisons use the character collating sequence specified by the LC_COLLATE locale.If you use a non-POSIX locale (e.g., by setting LC_ALL to ‘en_US’), then sort may produce output that is sorted differently than you're accustomed to. In that case, set the LC_ALL environment variable to ‘C’. Note that setting only LC_COLLATE has two problems. First, it is ineffective if LC_ALL is also set. Second, it has undefined behavior if LC_CTYPE (or LANG, if LC_CTYPE is unset) is set to an incompatible value. For example, you get undefined behavior if LC_CTYPE is ja_JP.PCK but LC_COLLATE is en_US.UTF-8. gnu 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, gnu sort silently supplies one. A line's trailing newline is not part of the line for comparison purposes. exit status of sort Exit status: 0 if no error occurred 1 if invoked with or and the input is not sorted 2 if an error occurred TMPDIR If the environment variable TMPDIR is set, sort uses its value as the directory for temporary files instead of /tmp. The () option in turn overrides the environment variable. 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-POSIX versions of sort, global options affect only later key fields, so portable shell scripts should specify global options first. -b’‘--ignore-leading-blanks -b –ignore-leading-blanks blanks, ignoring leading LC_CTYPEIgnore leading blanks when finding sort keys in each line.By default a blank is a space or a tab, but the LC_CTYPE localecan change this. -d’‘--dictionary-order -d –dictionary-order dictionary order phone directory order telephone directory order LC_CTYPESort in phone directory order: ignore all characters exceptletters, digits and blanks when sorting.By default letters and digits are those of ASCII and a blankis a space or a tab, but the LC_CTYPE locale can change this. -f’‘--ignore-case -f –ignore-case ignoring case case folding LC_CTYPEFold lowercase characters into the equivalent uppercase characters whencomparing so that, for example, ‘b’ and ‘B’ sort as equal.The LC_CTYPE locale determines character types. -g’‘--general-numeric-sort -g –general-numeric-sort general numeric sort LC_NUMERICSort numerically, using the standard C function strtod to converta prefix of each line to a double-precision floating point number.This allows floating point numbers to be specified in scientific notation,like 1.0e-34 and 10e100.The LC_NUMERIC locale determines the decimal-point character.Do not report overflow, underflow, or conversion errors.Use the following collating sequence: Lines that do not start with numbers (all considered to be equal). NaNs (“Not a Number” values, in IEEE floating point arithmetic)in a consistent but machine-dependent order. Minus infinity. Finite numbers in ascending numeric order (with -0 and +0 equal). Plus infinity. Use this option only if there is no alternative; it is much slower than () and it can lose information whenconverting to floating point. -i’‘--ignore-nonprinting -i –ignore-nonprinting nonprinting characters, ignoring unprintable characters, ignoring LC_CTYPEIgnore nonprinting characters.The LC_CTYPE locale determines character types.This option has no effect if the stronger () option is also given. -M’‘--month-sort -M –month-sort months, sorting by LC_TIMEAn initial string, consisting of any amount of blanks, followedby a month name abbreviation, is folded to UPPER case andcompared in the order ‘JAN’ < ‘FEB’ < … < ‘DEC’.Invalid names compare low to valid names. The LC_TIME localecategory determines the month spellings.By default a blank is a space or a tab, but the LC_CTYPE localecan change this. -n’‘--numeric-sort -n –numeric-sort numeric sort LC_NUMERICSort numerically. The number begins each line and consistsof optional blanks, an optional ‘-’ sign, and zero or moredigits possibly separated by thousands separators, optionally followedby a decimal-point character and zero or more digits. An emptynumber is treated as ‘0’. The LC_NUMERIClocale specifies the decimal-point character and thousands separator.By default a blank is a space or a tab, but the LC_CTYPE localecan change this.Comparison is exact; there is no rounding error.Neither a leading ‘+’ nor exponential notation is recognized.To compare such strings numerically, use the () option. -r’‘--reverse -r –reverse reverse sortingReverse the result of comparison, so that lines with greater key valuesappear earlier in the output instead of later. -R’‘--random-sort -R –random-sort random sortSort by hashing the input keys and then sorting the hash values.Choose the hash function at random, ensuring that it is free ofcollisions so that differing keys have differing hash values. This islike a random permutation of the inputs (see ),except that keys with the same value sort together.If multiple random sort fields are specified, the same random hashfunction is used for all fields. To use different random hashfunctions for different fields, you can invoke sort morethan once.The choice of hash function is affected by the option. Other options are: --compress-program=progCompress any temporary files with the program prog.With no arguments, prog must compress standard input to standardoutput, and when given the option it must decompressstandard input to standard output.Terminate with an error if prog exits with nonzero status.Whitespace and the backslash character should not appear inprog; they are reserved for future use. -k pos1[,pos2]’‘--key=pos1[,pos2] -k –key sort fieldSpecify a sort field that consists of the part of the line betweenpos1 and pos2 (or the end of the line, if pos2 isomitted), inclusive.Each pos has the form ‘f[.c][opts]’,where f is the number of the field to use, and c is the numberof the first character from the beginning of the field. Fields and characterpositions are numbered starting with 1; a character position of zero inpos2 indicates the field's last character. If ‘.c’ isomitted from pos1, it defaults to 1 (the beginning of the field);if omitted from pos2, it defaults to 0 (the end of the field).opts are ordering options, allowing individual keys to be sortedaccording to different rules; see below for details. Keys can spanmultiple fields.Example: To sort on the second field, use (). See below for more examples. -o output-file’‘--output=output-file -o –output overwriting of input, allowedWrite output to output-file instead of standard output.Normally, sort reads all input before openingoutput-file, so you can safely sort a file in place by usingcommands like sort -o F F and cat F | sort -o F.However, sort with () can openthe output file before reading all input, so a command like catF | sort -m -o F - G is not safe as sort might startwriting F before cat is done reading it. POSIXLY_CORRECTOn newer systems, cannot appear after an input file ifPOSIXLY_CORRECT is set, e.g., ‘sort F -o F’. Portablescripts should specify before any inputfiles. --random-source=file –random-source random source for sortingUse file as a source of random data used to determine whichrandom hash function to use with the option. See . -s’‘--stable -s –stable sort stability sort's last-resort comparisonMake sort stable by disabling its last-resort comparison.This option has no effect if no fields or global ordering optionsother than () are specified. -S size’‘--buffer-size=size -S –buffer-size size for main memory sortingUse a main-memory sort buffer of the given size. By default,size is in units of 1024 bytes. Appending ‘%’ causessize to be interpreted as a percentage of physical memory.Appending ‘K’ multiplies size by 1024 (the default),‘M’ by 1,048,576, ‘G’ by 1,073,741,824, and so on for‘T’, ‘P’, ‘E’, ‘Z’, and ‘Y’. Appending‘b’ causes size to be interpreted as a byte count, with nomultiplication.This option can improve the performance of sort by causing itto start with a larger or smaller sort buffer than the default.However, this option affects only the initial buffer size. The buffergrows beyond size if sort encounters input lines largerthan size. -t separator’‘--field-separator=separator -t –field-separator field separator characterUse character separator as the field separator when finding thesort keys in each line. By default, fields are separated by the emptystring between a non-blank character and a blank character.By default a blank is a space or a tab, but the LC_CTYPE localecan change this.That is, given the input line ‘ foo bar, sort breaks itinto fields ‘ foo and ‘ bar. The field separator isnot considered to be part of either the field preceding or the fieldfollowing, so with ‘sort -t " "’ the same input line hasthree fields: an empty field, ‘foo’, and ‘bar’.However, fields that extend to the end of the line,as , or fields consisting of a range, as ,retain the field separators present between the endpoints of the range.To specify a null character (ASCII nul) asthe field separator, use the two-character string ‘\0’, e.g.,‘sort -t '\0'’. -T tempdir’‘--temporary-directory=tempdir -T –temporary-directory temporary directory TMPDIRUse directory tempdir to store temporary files, overriding theTMPDIR environment variable. If this option is given more thanonce, temporary files are stored in all the directories given. If youhave a large sort or merge that is I/O-bound, you can often improveperformance by using this option to specify directories on differentdisks and controllers. -u’‘--unique -u –unique uniquifying outputNormally, output only the first of a sequence of lines that compareequal. For the ( or ) option,check that no pair of consecutive lines compares equal.This option also disables the default last-resort comparison.The commands sort -u and sort | uniq are equivalent, butthis equivalence does not extend to arbitrary sort options.For example, sort -n -u inspects only the value of the initialnumeric string when checking for uniqueness, whereas sort -n |uniq inspects the entire line. See . -z’‘--zero-terminated -z –zero-terminated sort zero-terminated linesTreat the input as a set of lines, each terminated by a null character(ASCII nul) instead of a line feed(ASCII lf).This option can be useful in conjunction with ‘perl -0’ or‘find -print0’ and ‘xargs -0’ which do the same in order toreliably handle arbitrary file names (even those containing blanksor other special characters). Historical (BSD and System V) implementations of sort have differed in their interpretation of some options, particularly , , and . gnu sort follows the POSIX behavior, which is usually (but not always!) like the System V behavior. According to POSIX, no longer implies . For consistency, 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 . A position in a sort field specified with may have any of the option letters ‘Mbdfinr’ appended to it, in which case the global ordering options are not used for that particular field. The option may be independently attached to either or both of the start and end positions of a field specification, and if it is inherited from the global options it will be attached to both. If input lines can contain leading or adjacent blanks and is not used, then is typically combined with , , , or ; otherwise the varying numbers of leading blanks in fields can cause confusing results. If the start position in a sort field specifier falls after the end of the line or after the end field, the field is empty. If the option was specified, the ‘.c’ part of a field specification is counted from the first nonblank character of the field. _POSIX2_VERSION POSIXLY_CORRECT On older systems, sort supports an obsolete origin-zero syntax ‘+pos1 [-pos2]’ for specifying sort keys. This obsolete behavior can be enabled or disabled with the _POSIX2_VERSION environment variable (see ); it can also be enabled when POSIXLY_CORRECT is not set by using the obsolete syntax with ‘-pos2’ present. Scripts intended for use on standard hosts should avoid obsolete syntax and should use instead. For example, avoid ‘sort +2’, since it might be interpreted as either ‘sort ./+2’ or ‘sort -k 3’. If your script must also run on hosts that support only the obsolete syntax, it can use a test like ‘if sort -k 1 </dev/null >/dev/null 2>&1; then …’ to decide which syntax to use. Here are some examples to illustrate various combinations of options. Sort in descending (reverse) numeric order. sort -n -r Sort alphabetically, omitting the first and second fieldsand the blanks at the start of the third field.This uses a single key composed of the characters beginningat the start of the first nonblank character in field threeand extending to the end of each line. sort -k 3b Sort numerically on the second field and resolve ties by sortingalphabetically on the third and fourth characters of field five.Use ‘:’ as the field delimiter. sort -t : -k 2,2n -k 5.3,5.4 Note that if you had written instead of sort would have used all characters beginning in the second fieldand extending to the end of the line as the primary numerickey. For the large majority of applications, treating keys spanningmore than one field as numeric will not do what you expect.Also note that the ‘n’ modifier was applied to the field-endspecifier for the first key. It would have been equivalent tospecify or . All modifiers except‘b’ apply to the associated field, regardless of whetherthe modifier character is attached to the field-start and/or thefield-end part of the key specifier. Sort the password file on the fifth field and ignore anyleading blanks. Sort lines with equal values in field fiveon the numeric user ID in field three. Fields are separatedby ‘:’. sort -t : -k 5b,5 -k 3,3n /etc/passwd sort -t : -n -k 5b,5 -k 3,3 /etc/passwd sort -t : -b -k 5,5 -k 3,3n /etc/passwd These three commands have equivalent effect. The first specifies thatthe first key's start position ignores leading blanks and the secondkey is sorted numerically. The other two commands rely on globaloptions being inherited by sort keys that lack modifiers. The inheritanceworks in this case because and areequivalent, as the location of a field-end lacking a ‘.c’character position is not affected by whether initial blanks areskipped. Sort a set of log files, primarily by IPv4 address and secondarily bytime stamp. If two lines' primary and secondary keys are identical,output the lines in the same order that they were input. The logfiles contain lines that look like this: 4.150.156.3 - - [01/Apr/2004:06:31:51 +0000] message 1 211.24.3.231 - - [24/Apr/2004:20:17:39 +0000] message 2 Fields are separated by exactly one space. Sort IPv4 addresseslexicographically, e.g., 212.61.52.2 sorts before 212.129.233.201because 61 is less than 129. sort -s -t ' ' -k 4.9n -k 4.5M -k 4.2n -k 4.14,4.21 file*.log | sort -s -t '.' -k 1,1n -k 2,2n -k 3,3n -k 4,4n This example cannot be done with a single sort invocation,since IPv4 address components are separated by ‘.’ while datescome just after a space. So it is broken down into two invocations ofsort: the first sorts by time stamp and the second by IPv4address. The time stamp is sorted by year, then month, then day, andfinally by hour-minute-second field, using to isolate eachfield. Except for hour-minute-second there's no need to specify theend of each key field, since the ‘n’ and ‘M’ modifiers sortbased on leading prefixes that cannot cross field boundaries. TheIPv4 addresses are sorted lexicographically. The second sort uses‘-s’ so that ties in the primary key are broken by the secondarykey; the first sort uses ‘-s’ so that the combination of the twosorts is stable. Generate a tags file in case-insensitive sorted order. find src -type f -print0 | sort -z -f | xargs -0 etags --append The use of , , and in this case meansthat file names that contain blanks or other special characters arenot broken upby the sort operation. Shuffle a list of directories, but preserve the order of files withineach directory. For instance, one could use this to generate a musicplaylist in which albums are shuffled but the songs of each album areplayed in order. ls */* | sort -t / -k 1,1R -k 2,2 shuf: Shuffling text shuf shuffling files shuf shuffles its input by outputting a random permutation of its input lines. Each output permutation is equally likely. Synopses: shuf [option]… [file] shuf -e [option]… [arg]… shuf -i lo-hi [option]… shuf has three modes of operation that affect where it obtains its input lines. By default, it reads lines from standard input. The following options change the operation mode: -e’‘--echo -c –echo command-line operands to shuffleTreat each command-line operand as an input line. -i lo-hi’‘--input-range=lo-hi -i –input-range input range to shuffleAct as if input came from a file containing the range of unsigneddecimal integers lohi, one per line. shuf's other options can affect its behavior in all operation modes: -n lines’‘--head-lines=lines -n –head-lines head of outputOutput at most lines lines. By default, all input lines areoutput. -o output-file’‘--output=output-file -o –output overwriting of input, allowedWrite output to output-file instead of standard output.shuf reads all input before openingoutput-file, so you can safely shuffle a file in place by usingcommands like shuf -o F <F and cat F | shuf -o F. --random-source=file –random-source random source for shufflingUse file as a source of random data used to determine whichpermutation to generate. See . -z’‘--zero-terminated -z –zero-terminated sort zero-terminated linesTreat the input and output as a set of lines, each terminated by a zero byte(ASCII nul (Null) character) instead of anASCII lf (Line Feed).This option can be useful in conjunction with ‘perl -0’ or‘find -print0’ and ‘xargs -0’ which do the same in order toreliably handle arbitrary file names (even those containing blanksor other special characters). For example: shuf <<EOF A man, a plan, a canal: Panama! EOF might produce the output Panama! A man, a canal: a plan, Similarly, the command: shuf -e clubs hearts diamonds spades might output: clubs diamonds spades hearts and the command ‘shuf -i 1-4’ might output: 4 2 1 3 These examples all have four input lines, so shuf might produce any of the twenty-four possible permutations of the input. In general, if there are N input lines, there are N! (i.e., N factorial, or N * (N - 1) * … * 1) possible output permutations. An exit status of zero indicates success, and a nonzero value indicates failure. uniq: Uniquify files uniq uniquify files uniq writes the unique lines in the given input, or standard input if nothing is given or for an input name of ‘-’. Synopsis: uniq [option]… [input [output]] By default, uniq prints its input lines, except that it discards all but the first of adjacent repeated lines, so that no output lines are repeated. Optionally, it can instead discard lines that are not repeated, or all repeated lines. The input need not be sorted, but repeated input lines are detected only if they are adjacent. If you want to discard non-adjacent duplicate lines, perhaps you want to use sort -u. See . LC_COLLATE Comparisons use the character collating sequence specified by the LC_COLLATE locale category. If no output file is specified, uniq writes to standard output. The program accepts the following options. Also see . -f n’‘--skip-fields=n -f –skip-fieldsSkip n fields on each line before checking for uniqueness. Usea null string for comparison if a line has fewer than n fields. Fieldsare sequences of non-space non-tab characters that are separated fromeach other by at least one space or tab.For compatibility uniq supports an obsolete option syntax. New scripts should use instead. -s n’‘--skip-chars=n -s –skip-charsSkip n characters before checking for uniqueness. Use a null stringfor comparison if a line has fewer than n characters. If you use boththe field and character skipping options, fields are skipped over first. _POSIX2_VERSIONOn older systems, uniq supports an obsolete option syntax.This obsolete behavior can be enabled or disabled with the_POSIX2_VERSION environment variable (see ), but portable scripts should avoid commands whosebehavior depends on this variable.For example, use ‘uniq ./+10’ or ‘uniq -s 10’ rather thanthe ambiguous ‘uniq +10’. -c’‘--count -c –countPrint the number of times each line occurred along with the line. -i’‘--ignore-case -i –ignore-caseIgnore differences in case when comparing lines. -d’‘--repeated -d –repeated repeated lines, outputtingDiscard lines that are not repeated. When used by itself, this optioncauses uniq to print the first copy of each repeated line,and nothing else. -D’‘--all-repeated[=delimit-method] -D –all-repeated all repeated lines, outputtingDo not discard the second and subsequent repeated input lines,but discard lines that are not repeated.This option is useful mainly in conjunction with other options e.g.,to ignore case or to compare only selected fields.The optional delimit-method tells how to delimitgroups of repeated lines, and must be one of the following: noneDo not delimit groups of repeated lines.This is equivalent to (). prependOutput a newline before each group of repeated lines. separateSeparate groups of repeated lines with a single newline.This is the same as using ‘prepend’, except thatthere is no newline before the first group, and hencemay be better suited for output direct to users. Note that when groups are delimited and the input stream containstwo or more consecutive blank lines, then the output is ambiguous.To avoid that, filter the input through ‘tr -s '\n'’ to replaceeach sequence of consecutive newlines with a single newline.This is a gnu extension. -u’‘--unique -u –unique unique lines, outputtingDiscard the first repeated line. When used by itself, this optioncauses uniq to print unique lines, and nothing else. -w n’‘--check-chars=n -w –check-charsCompare at most n characters on each line (after skipping any specifiedfields and characters). By default the entire rest of the lines arecompared. An exit status of zero indicates success, and a nonzero value indicates failure. comm: Compare two sorted files line by line comm line-by-line comparison comparing sorted files comm writes to standard output lines that are common, and lines that are unique, to two input files; a file name of ‘-’ means standard input. Synopsis: comm [option]… file1 file2 LC_COLLATE Before comm can be used, the input files must be sorted using the collating sequence specified by the LC_COLLATE locale. If an input file ends in a non-newline character, a newline is silently appended. The sort command with no options always outputs a file that is suitable input to comm. differing lines common lines With no options, comm produces three-column output. Column one contains lines unique to file1, column two contains lines unique to file2, and column three contains lines common to both files. Columns are separated by a single TAB character. -1 -2 -3 The options , , and suppress printing of the corresponding columns. Also see . Unlike some other comparison utilities, comm has an exit status that does not depend on the result of the comparison. Upon normal completion comm produces an exit code of zero. If there is an error it exits with nonzero status. tsort: Topological sort tsort topological sort tsort performs a topological sort on the given file, or standard input if no input file is given or for a file of ‘-’. For more details and some history, see . Synopsis: tsort [option] [file] tsort reads its input as pairs of strings, separated by blanks, indicating a partial ordering. The output is a total ordering that corresponds to the given partial ordering. For example tsort <<EOF a b c d e f b c d e EOF will produce the output a b c d e f Consider a more realistic example. You have a large set of functions all in one file, and they may all be declared static except one. Currently that one (say main) is the first function defined in the file, and the ones it calls directly follow it, followed by those they call, etc. Let's say that you are determined to take advantage of prototypes, so you have to choose between declaring all of those functions (which means duplicating a lot of information from the definitions) and rearranging the functions so that as many as possible are defined before they are used. One way to automate the latter process is to get a list for each function of the functions it calls directly. Many programs can generate such lists. They describe a call graph. Consider the following list, in which a given line indicates that the function on the left calls the one on the right directly. main parse_options main tail_file main tail_forever tail_file pretty_name tail_file write_header tail_file tail tail_forever recheck tail_forever pretty_name tail_forever write_header tail_forever dump_remainder tail tail_lines tail tail_bytes tail_lines start_lines tail_lines dump_remainder tail_lines file_lines tail_lines pipe_lines tail_bytes xlseek tail_bytes start_bytes tail_bytes dump_remainder tail_bytes pipe_bytes file_lines dump_remainder recheck pretty_name then you can use tsort to produce an ordering of those functions that satisfies your requirement. example$ tsort call-graph | tac dump_remainder start_lines file_lines pipe_lines xlseek start_bytes pipe_bytes tail_lines tail_bytes pretty_name write_header tail recheck parse_options tail_file tail_forever main tsort detects any cycles in the input and writes the first cycle encountered to standard error. Note that for a given partial ordering, generally there is no unique total ordering. In the context of the call graph above, the function parse_options may be placed anywhere in the list as long as it precedes main. The only options are and . See . tsort: Background tsort exists because very early versions of the Unix linker processed an archive file exactly once, and in order. As ld read each object in the archive, it decided whether it was needed in the program based on whether it defined any symbols which were undefined at that point in the link. This meant that dependencies within the archive had to be handled specially. For example, scanf probably calls read. That means that in a single pass through an archive, it was important for scanf.o to appear before read.o, because otherwise a program which calls scanf but not read might end up with an unexpected unresolved reference to read. The way to address this problem was to first generate a set of dependencies of one object file on another. This was done by a shell script called lorder. The GNU tools don't provide a version of lorder, as far as I know, but you can still find it in BSD distributions. Then you ran tsort over the lorder output, and you used the resulting sort to define the order in which you added objects to the archive. This whole procedure has been obsolete since about 1980, because Unix archives now contain a symbol table (traditionally built by ranlib, now generally built by ar itself), and the Unix linker uses the symbol table to effectively make multiple passes over an archive file. Anyhow, that's where tsort came from. To solve an old problem with the way the linker handled archive files, which has since been solved in different ways. An exit status of zero indicates success, and a nonzero value indicates failure. ptx: Produce permuted indexes ptx ptx reads a text file and essentially produces a permuted index, with each keyword in its context. The calling sketch is either one of: ptx [option …] [file …] ptx -G [option …] [input [output]] The (or its equivalent: ) option disables all gnu extensions and reverts to traditional mode, thus introducing some limitations and changing several of the program's default option values. When is not specified, gnu extensions are always enabled. gnu extensions to ptx are documented wherever appropriate in this document. For the full list, see See . Individual options are explained in the following sections. When gnu extensions are enabled, there may be zero, one or several files after the options. If there is no file, the program reads the standard input. If there is one or several files, they give the name of input files which are all read in turn, as if all the input files were concatenated. However, there is a full contextual break between each file and, when automatic referencing is requested, 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 gnu extensions are 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. If there is only one parameter, it names the text input to be read instead of the standard input. If two parameters are given, they give respectively the name of the input file to read and the name of the output file to produce. 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 ptx compatibility; gnu Standards normally discourage output parameters not introduced by an option. Note that for any file named as the value of an option or as an input text file, a single dash - may be used, in which case standard input is assumed. However, it would not make sense to use this convention more than once per program invocation. General options -G’‘--traditionalAs already explained, this option disables all gnu extensions toptx and switches to traditional mode. --helpPrint a short help on standard output, then exit without furtherprocessing. --versionPrint the program version on standard output, then exit without furtherprocessing. An exit status of zero indicates success, and a nonzero value indicates failure. Charset selection As it is set up now, the program assumes that the input file is coded using 8-bit ISO 8859-1 code, also known as Latin-1 character set, unless it is compiled for MS-DOS, in which case it uses the character set of the IBM-PC. (gnu 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, however, is still crude; it obeys the underlying character set ordering quite blindly. -f’‘--ignore-caseFold lower case letters to upper case for sorting. Word selection and input processing -b file’‘--break-file=fileThis option provides an alternative (to ) method of describingwhich characters make up words. It introduces the name of afile which contains a list of characters which cannot be part ofone word; this file is called the Break file. Any character whichis not part of the Break file is a word constituent. If both options and are specified, then has precedence and is ignored.When gnu extensions are enabled, the only way to avoid newline as abreak character is to write all the break characters in the file with nonewline at all, not even at the end of the file. When gnu extensionsare disabled, spaces, tabs and newlines are always considered as breakcharacters even if not included in the Break file. -i file’‘--ignore-file=fileThe file associated with this option contains a list of words which willnever be taken as keywords in concordance output. It is called theIgnore file. The file contains exactly one word in each line; theend of line separation of words is not subject to the value of the option. -o file’‘--only-file=fileThe file associated with this option contains a list of words which willbe retained in concordance output; any word not mentioned in this fileis ignored. The file is called the Only file. The file containsexactly one word in each line; the end of line separation of words isnot subject to the value of the option.There is no default for the Only file. When both an Only file and anIgnore file are specified, a word is considered a keyword onlyif it is listed in the Only file and not in the Ignore file. -r’‘--referencesOn each input line, the leading sequence of non-white space characters will betaken to be a reference that has the purpose of identifying this inputline in the resulting permuted index. For more information about referenceproduction, see See .Using this option changes the default value for option .Using this option, the program does not try very hard to removereferences from contexts in output, but it succeeds in doing sowhen the context ends exactly at the newline. If option is used with default value, or when gnu extensionsare disabled, this condition is always met and references are completelyexcluded from the output contexts. -S regexp’‘--sentence-regexp=regexpThis option selects which regular expression will describe the end of aline or the end of a sentence. In fact, this regular expression is notthe only distinction between end of lines or end of sentences, and inputline boundaries have no special significance outside this option. Bydefault, when gnu extensions are enabled and if option is notused, end of sentences are used. In this case, this regex isimported from gnu Emacs: [.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]* Whenever gnu extensions are disabled or if option is used, endof lines are used; in this case, the default regexp is just: \n Using an empty regexp is equivalent to completely disabling end ofline or end of sentence recognition. In this case, the whole file isconsidered to be a single big line or sentence. The user might want todisallow all truncation flag generation as well, through option . See See section ``Syntax of Regular Expressions'' in The GNU Emacs Manual.When the keywords happen to be near the beginning of the input line orsentence, this often creates an unused area at the beginning of theoutput context line; when the keywords happen to be near the end of theinput line or sentence, this often creates an unused area at the end ofthe output context line. The program tries to fill those unused areasby wrapping around context in them; the tail of the input line orsentence is used to fill the unused area on the left of the output line;the head of the input line or sentence is used to fill the unused areaon the right of the output line.As a matter of convenience to the user, many usual backslashed escapesequences from the C language are recognized and converted to thecorresponding characters by ptx itself. -W regexp’‘--word-regexp=regexpThis option selects which regular expression will describe each keyword.By default, if gnu extensions are enabled, a word is a sequence ofletters; the regexp used is ‘\w+’. When gnu extensions aredisabled, a word is by default anything which ends with a space, a tabor a newline; the regexp used is ‘[^ \t\n]+’.An empty regexp is equivalent to not using this option.See See section ``Syntax of Regular Expressions'' in The GNU Emacs Manual.As a matter of convenience to the user, many usual backslashed escapesequences, as found in the C language, are recognized and converted tothe corresponding characters by ptx itself. Output formatting Output format is mainly controlled by the and options described in the table below. When neither nor are 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 and are output before the left context, that is, if option is not selected, then a colon is added after the reference; this nicely interfaces with gnu Emacs 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 spaces. This might change in the future. Except for those white space characters, every other character of the underlying set of 256 characters is transmitted verbatim. Output format is further controlled by the following options. -g number’‘--gap-size=numberSelect the size of the minimum white space gap between the fields on theoutput line. -w number’‘--width=numberSelect the maximum output width of each final line. If references areused, they are included or excluded from the maximum output widthdepending on the value of option . If this option is notselected, that is, when references are output before the left context,the maximum output width takes into account the maximum length of allreferences. If this option is selected, that is, when references areoutput after the right context, the maximum output width does not takeinto account the space taken by references, nor the gap that precedesthem. -A’‘--auto-referenceSelect automatic references. Each input line will have an automaticreference made up of the file name and the line ordinal, with a singlecolon between them. However, the file name will be empty when standardinput is being read. If both and are selected, thenthe input reference is still read and skipped, but the automaticreference is used at output time, overriding the input reference. -R’‘--right-side-refsIn the default output format, when option is not used, anyreferences produced by the effect of options or areplaced to the far right of output lines, after the right context. Withdefault output format, when the option is specified, referencesare rather placed at the beginning of each output line, before the leftcontext. For any other output format, option isignored, with one exception: with the width of referencesis not taken into account in total output width given by .This option is automatically selected whenever gnu extensions aredisabled. -F string’‘--flac-truncation=stringThis option will request that any truncation in the output be reportedusing the string string. Most output fields theoretically extendtowards the beginning or the end of the current line, or currentsentence, as selected with option . But there is a maximumallowed output line width, changeable through option , which isfurther divided into space for various output fields. When a field hasto be truncated because it cannot extend beyond the beginning or the end ofthe current line to fit in, then a truncation occurs. By default,the string used is a single slash, as in .string may have more than one character, as in .Also, in the particular case when string is empty (),truncation flagging is disabled, and no truncation marks are appended inthis case.As a matter of convenience to the user, many usual backslashed escapesequences, as found in the C language, are recognized and converted tothe corresponding characters by ptx itself. -M string’‘--macro-name=stringSelect another string to be used instead of ‘xx’, whilegenerating output suitable for nroff, troff or &tex;. -O’‘--format=roffChoose an output format suitable for nroff or troffprocessing. Each output line will look like: .xx "tail" "before" "keyword_and_after" "head" "ref" so it will be possible to write a ‘.xx’ roff macro to take care ofthe output typesetting. This is the default output format when gnuextensions are disabled. Option can be used to change‘xx’ to another macro name.In this output format, each non-graphical character, like newline andtab, is merely changed to exactly one space, with no special attempt tocompress consecutive spaces. Each quote character: " is doubledso it will be correctly processed by nroff or troff. -T’‘--format=texChoose an output format suitable for &tex; processing. Each outputline will look like: \xx {tail}{before}{keyword}{after}{head}{ref} so it will be possible to write a \xx definition to take care ofthe output typesetting. Note that when references are not beingproduced, that is, neither option nor option isselected, the last parameter of each \xx call is inhibited.Option can be used to change ‘xx’ to another macroname.In this output format, some special characters, like $, %,&, # and _ are automatically protected with abackslash. Curly brackets {, } are protected with abackslash and a pair of dollar signs (to force mathematical mode). Thebackslash itself produces the sequence \backslash{}.Circumflex and tilde diacritical marks produce the sequence ^\{ } and~\{ } respectively. Other diacriticized characters of theunderlying character set produce an appropriate &tex; sequence as faras possible. The other non-graphical characters, like newline and tab,and all other characters which are not part of ASCII, are merelychanged to exactly one space, with no special attempt to compressconsecutive spaces. Let me know how to improve this special characterprocessing for &tex;. The gnu extensions to ptx This version of ptx contains a few features which do not exist in System V ptx. These extra features are suppressed by using the command line option, unless overridden by other command line options. Some gnu extensions cannot be recovered by overriding, so the simple rule is to avoid if you care about gnu extensions. Here are the differences between this program and System V ptx. This program can read many input files at once, it always writes theresulting concordance on standard output. On the other hand, System Vptx reads only one file and sends the result to standard outputor, if a second file parameter is given on the command, to thatfile.Having output parameters not introduced by options is a dangerouspractice which gnu avoids as far as possible. So, for using ptxportably between gnu and System V, you should always use it with asingle input file, and always expect the result on standard output. Youmight also want to automatically configure in a option toptx calls in products using ptx, if the configurator findsthat the installed ptx accepts . The only options available in System V ptx are options ,, , , , , and. All other options are gnu extensions and are not repeated inthis enumeration. Moreover, some options have a slightly differentmeaning when gnu extensions are enabled, as explained below. By default, concordance output is not formatted for troff ornroff. It is rather formatted for a dumb terminal. troffor nroff output may still be selected through option . Unless option is used, the maximum reference width issubtracted from the total output line width. With gnu extensionsdisabled, width of references is not taken into account in the outputline width computations. All 256 bytes, even null bytes, are always read and processed frominput file with no adverse effect, even if gnu extensions are disabled.However, System V ptx does not accept 8-bit characters, a fewcontrol characters are rejected, and the tilde ~ is also rejected. Input line length is only limited by available memory, even if gnuextensions are disabled. However, System V ptx processes onlythe first 200 characters in each line. The break (non-word) characters default to be every character except allletters of the underlying character set, diacriticized or not. When gnuextensions are disabled, the break characters default to space, tab andnewline only. The program makes better use of output line width. If gnu extensionsare disabled, the program rather tries to imitate System V ptx,but still, there are some slight disposition glitches this program doesnot completely reproduce. The user can specify both an Ignore file and an Only file. This is notallowed with System V ptx. Operating on fields within a line cut: Print selected parts of lines cut cut writes to standard output selected parts of each line of each input file, or standard input if no files are given or for a file name of ‘-’. Synopsis: cut [option]… [file]… In the table which follows, the byte-list, character-list, and field-list are one or more numbers or ranges (two numbers separated by a dash) separated by commas. Bytes, characters, and fields are numbered starting at 1. Incomplete ranges may be given: means ‘1-m’; ‘n-’ means ‘n’ through end of line or last field. The list elements can be repeated, can overlap, and can be specified in any order; but the selected input is written in the same order that it is read, and is written exactly once. The program accepts the following options. Also see . -b byte-list’‘--bytes=byte-list -b –bytesSelect for printing only the bytes in positions listed inbyte-list. Tabs and backspaces are treated like any othercharacter; they take up 1 byte. If an output delimiter is specified,(see the description of ), then output thatstring between ranges of selected bytes. -c character-list’‘--characters=character-list -c –charactersSelect for printing only the characters in positions listed incharacter-list. The same as for now, butinternationalization will change that. Tabs and backspaces aretreated like any other character; they take up 1 character. If anoutput delimiter is specified, (see the description of), then output that string between rangesof selected bytes. -f field-list’‘--fields=field-list -f –fieldsSelect for printing only the fields listed in field-list.Fields are separated by a TAB character by default. Also print anyline that contains no delimiter character, unless the () option is specified -d input_delim_byte’‘--delimiter=input_delim_byte -d –delimiterWith , use the first byte of input_delim_byte asthe input fields separator (default is TAB). -n -nDo not split multi-byte characters (no-op for now). -s’‘--only-delimited -s –only-delimitedFor , do not print lines that do not contain the field separatorcharacter. Normally, any line without a field separator is printed verbatim. --output-delimiter=output_delim_string –output-delimiterWith , output fields are separated by output_delim_string.The default with is to use the input delimiter.When using or to select ranges of byte orcharacter offsets (as opposed to ranges of fields),output output_delim_string between non-overlappingranges of selected bytes. --complement –complementThis option is a GNU extension.Select for printing the complement of the bytes, characters or fieldsselected with the , or options.In other words, do not print the bytes, characters or fieldsspecified via those options. This option is useful when you havemany fields and want to print all but a few of them. An exit status of zero indicates success, and a nonzero value indicates failure. paste: Merge lines of files paste merging files paste writes to standard output lines consisting of sequentially corresponding lines of each given file, separated by a TAB character. Standard input is used for a file name of ‘-’ or if no input files are given. For example: $ cat num2 1 2 $ cat let3 a b c $ paste num2 let3 1 a 2 b c Synopsis: paste [option]… [file]… The program accepts the following options. Also see . -s’‘--serial -s –serialPaste the lines of one file at a time rather than one line from eachfile. Using the above example data: $ paste -s num2 let3 1 2 a b c -d delim-list’‘--delimiters=delim-list -d –delimitersConsecutively use the characters in delim-list instead ofTAB to separate merged lines. When delim-list isexhausted, start again at its beginning. Using the above example data: $ paste -d '%_' num2 let3 num2 1%a_1 2%b_2 %c_ An exit status of zero indicates success, and a nonzero value indicates failure. join: Join lines on a common field join common field, joining on join writes to standard output a line for each pair of input lines that have identical join fields. Synopsis: join [option]… file1 file2 Either file1 or file2 (but not both) can be ‘-’, meaning standard input. file1 and file2 should be sorted on the join fields. LC_COLLATE Normally, the sort order is that of the collating sequence specified by the LC_COLLATE locale. Unless the option is given, the sort comparison ignores blanks at the start of the join field, as in sort -b. If the option is given, the sort comparison ignores the case of characters in the join field, as in sort -f. The sort and join commands should use consistent locales and options if the output of sort is fed to join. You can use a command like ‘sort -k 1b,1’ to sort a file on its default join field, but if you select a non-default locale, join field, separator, or comparison options, then you should do so consistently between join and sort. As a GNU extension, if the input has no unpairable lines 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: $ cat file1 a a1 c c1 b b1 $ cat file2 a a2 c c2 b b2 $ join file1 file2 a a1 a2 c c1 c2 b b1 b2 The defaults are: the join field is the first field in each line; fields in the input are separated by one or more blanks, with leading blanks on the line ignored; fields in the output are separated by a space; each output line consists of the join field, the remainingfields from file1, then the remaining fields from file2. The program accepts the following options. Also see . -a file-number -aPrint a line for each unpairable line in file file-number (either‘1’ or ‘2’), in addition to the normal output. -e string -eReplace those output fields that are missing in the input withstring. -i’‘--ignore-case -i –ignore-caseIgnore differences in case when comparing keys.With this option, the lines of the input files must be ordered in the same way.Use ‘sort -f’ to produce this ordering. -1 field -1Join on field field (a positive integer) of file 1. -2 field -2Join on field field (a positive integer) of file 2. -j fieldEquivalent to . -o field-listConstruct each output line according to the format in field-list.Each element in field-list is either the single character ‘0’ orhas the form m.n where the file number, m, is ‘1’ or‘2’ and n is a positive field number.A field specification of ‘0’ denotes the join field.In most cases, the functionality of the ‘0’ field specmay be reproduced using the explicit m.n that correspondsto the join field. However, when printing unpairable lines(using either of the or options), there is no wayto specify the join field using m.n in field-listif there are unpairable lines in both files.To give join that functionality, POSIX invented the ‘0’field specification notation.The elements in field-listare separated by commas or blanks.Blank separators typically need to be quoted for the shell. Forexample, the commands ‘join -o 1.2,2.2’ and ‘join -o '1.22.2'’ are equivalent.All output lines—including those printed because of any -a or -voption—are subject to the specified field-list. -t charUse character char as the input and output field separator.Treat as significant each occurrence of char in the input file.Use ‘sort -t char’, without the option of‘sort’, to produce this ordering. -v file-numberPrint a line for each unpairable line in file file-number(either ‘1’ or ‘2’), instead of the normal output. An exit status of zero indicates success, and a nonzero value indicates failure. Operating on characters operating on characters This commands operate on individual characters. tr: Translate, squeeze, and/or delete characters tr Synopsis: tr [option]… set1 [set2] tr copies standard input to standard output, performing one of the following operations: translate, and optionally squeeze repeated characters in the result, squeeze repeated characters, delete characters, delete characters, then squeeze repeated characters from the result. The set1 and (if given) set2 arguments define ordered sets of characters, referred to below as set1 and set2. These sets are the characters of the input that tr operates on. The (, ) option replaces set1 with its complement (all of the characters that are not in set1). Currently tr fully supports only single-byte characters. Eventually it will support multibyte characters; when it does, the option will cause it to complement the set of characters, whereas will cause it to complement the set of values. This distinction will matter only when some values are not characters, and this is possible only in locales using multibyte encodings when the input contains encoding errors. The program accepts the and options. See . Options must precede operands. An exit status of zero indicates success, and a nonzero value indicates failure. Specifying sets of characters specifying sets of characters The format of the set1 and set2 arguments resembles the format of regular expressions; however, they are not regular expressions, only lists of characters. Most characters simply represent themselves in these strings, but the strings can contain the shorthands listed below, for convenience. Some of them can be used only in set1 or set2, as noted below. Backslash escapes backslash escapesThe following backslash escape sequences are recognized: \aControl-G. \bControl-H. \fControl-L. \nControl-J. \rControl-M. \tControl-I. \vControl-K. \oooThe character with the value given by ooo, which is 1 to 3octal digits, \\A backslash. While a backslash followed by a character not listed above isinterpreted as that character, the backslash also effectivelyremoves any special significance, so it is useful to escape‘[’, ‘]’, ‘*’, and ‘-’. Ranges rangesThe notation ‘m-n’ expands to all of the charactersfrom m through n, in ascending order. m shouldcollate before n; if it doesn't, an error results. As an example,‘0-9’ is the same as ‘0123456789’.gnu tr does not support the System V syntax that uses squarebrackets to enclose ranges. Translations specified in that formatsometimes work as expected, since the brackets are often transliteratedto themselves. However, they should be avoided because they sometimesbehave unexpectedly. For example, ‘tr -d '[0-9]'’ deletes bracketsas well as digits.Many historically common and even accepted uses of ranges are notportable. For example, on EBCDIC hosts using the ‘A-Z’range will not do what most would expect because ‘A’ through ‘Z’are not contiguous as they are in ASCII.If you can rely on a POSIX compliant version of tr, thenthe best way to work around this is to use character classes (see below).Otherwise, it is most portable (and most ugly) to enumerate the membersof the ranges. Repeated characters repeated charactersThe notation ‘[c*n]’ in set2 expands to ncopies of character c. Thus, ‘[y*6]’ is the same as‘yyyyyy’. The notation ‘[c*]’ in string2 expandsto as many copies of c as are needed to make set2 as long asset1. If n begins with ‘0’, it is interpreted inoctal, otherwise in decimal. Character classes character classesThe notation ‘[:class:]’ expands to all of the characters inthe (predefined) class class. The characters expand in noparticular order, except for the upper and lower classes,which expand in ascending order. When the ()and () options are both given, anycharacter class can be used in set2. Otherwise, only thecharacter classes lower and upper are accepted inset2, and then only if the corresponding character class(upper and lower, respectively) is specified in the samerelative position in set1. Doing this specifies case conversion.The class names are given below; an error results when an invalid classname is given. alnum alnumLetters and digits. alpha alphaLetters. blank blankHorizontal whitespace. cntrl cntrlControl characters. digit digitDigits. graph graphPrintable characters, not including space. lower lowerLowercase letters. print printPrintable characters, including space. punct punctPunctuation characters. space spaceHorizontal or vertical whitespace. upper upperUppercase letters. xdigit xdigitHexadecimal digits. Equivalence classes equivalence classesThe syntax ‘[=c=]’ expands to all of the characters that areequivalent to c, in no particular order. Equivalence classes area relatively recent invention intended to support non-English alphabets.But there seems to be no standard way to define them or determine theircontents. Therefore, they are not fully implemented in gnu tr;each character's equivalence class consists only of that character,which is of no particular use. Translating translating characters tr performs translation when set1 and set2 are both given and the () option is not given. tr translates each character of its input that is in set1 to the corresponding character in set2. Characters not in set1 are passed through unchanged. When a character appears more than once in set1 and the corresponding characters in set2 are not all the same, only the final one is used. For example, these two commands are equivalent: tr aaa xyz tr a z A common use of tr is to convert lowercase characters to uppercase. This can be done in many ways. Here are three of them: tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ tr a-z A-Z tr '[:lower:]' '[:upper:]' But note that using ranges like a-z above is not portable. When tr is performing translation, set1 and set2 typically have the same length. If set1 is shorter than set2, the extra characters at the end of set2 are ignored. On the other hand, making set1 longer than set2 is not portable; POSIX says that the result is undefined. In this situation, BSD tr pads set2 to the length of set1 by repeating the last character of set2 as many times as necessary. System V tr truncates set1 to the length of set2. By default, gnu tr handles this case like BSD tr. When the () option is given, gnu tr handles this case like the System V tr instead. This option is ignored for operations other than translation. Acting like System V tr in this case breaks the relatively common BSD idiom: tr -cs A-Za-z0-9 '\012' because it converts only zero bytes (the first element in the complement of set1), rather than all non-alphanumerics, to newlines. 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 POSIX compliant tr, here is a better way to write it: tr -cs '[:alnum:]' '[\n*]' Squeezing repeats and deleting squeezing repeat characters deleting characters When given just the () option, tr removes any input characters that are in set1. When given just the () option, tr replaces each input sequence of a repeated character that is in set1 with a single occurrence of that character. When given both and , tr first performs any deletions using set1, then squeezes repeats from any remaining characters using set2. The option may also be used when translating, in which case tr first performs translation, then squeezes repeats from any remaining characters using set2. Here are some examples to illustrate various combinations of options: Remove all zero bytes: tr -d '\0' Put all words on lines by themselves. This converts allnon-alphanumeric characters to newlines, then squeezes each stringof repeated newlines into a single newline: tr -cs '[:alnum:]' '[\n*]' Convert each sequence of repeated newlines to a single newline: tr -s '\n' Find doubled occurrences of words in a document. For example, people often write “the the” with the repeated wordsseparated by a newline. The Bourne shell script below works firstby converting each sequence of punctuation and blank characters to asingle newline. That puts each “word” on a line by itself.Next it maps all uppercase characters to lower case, and finally itruns uniq with the option to print out only the wordsthat were repeated. #!/bin/sh cat -- "$@" \ | tr -s '[:punct:][:blank:]' '[\n*]' \ | tr '[:upper:]' '[:lower:]' \ | uniq -d Deleting a small set of characters is usually straightforward. For example,to remove all ‘a’s, ‘x’s, and ‘M’s you would do this: tr -d axM However, when ‘-’ is one of those characters, it can be tricky because‘-’ has special meanings. Performing the same task as above but alsoremoving all ‘-’ characters, we might try tr -d -axM, butthat would fail because tr would try to interpret asa command-line option. Alternatively, we could try putting the hypheninside the string, tr -d a-xM, but that wouldn't work either becauseit would make tr interpret a-x as the range of characters‘a’…‘x’ rather than the three.One way to solve the problem is to put the hyphen at the end of the listof characters: tr -d axM- Or you can use ‘--’ to terminate option processing: tr -d -- -axM More generally, use the character class notation [=c=]with ‘-’ (or any other character) in place of the ‘c’: tr -d '[=-=]axM' Note how single quotes are used in the above example to protect thesquare brackets from interpretation by a shell. expand: Convert tabs to spaces expand tabs to spaces, converting converting tabs to spaces expand writes the contents of each given file, or standard input if none are given or for a file of ‘-’, to standard output, with tab characters converted to the appropriate number of spaces. Synopsis: expand [option]… [file]… By default, expand converts all tabs to spaces. It preserves backspace characters in the output; they decrement the column count for tab calculations. The default action is equivalent to (set tabs every 8 columns). The program accepts the following options. Also see . -t tab1[,tab2]…’‘--tabs=tab1[,tab2]… -t –tabs tab stops, settingIf only one tab stop is given, set the tabs tab1 spaces apart(default is 8). Otherwise, set the tabs at columns tab1,tab2, … (numbered from 0), and replace any tabs beyond thelast tab stop given with single spaces. Tab stops can be separated byblanks as well as by commas.For compatibility, GNU expand also accepts the obsoleteoption syntax, . New scriptsshould use instead. -i’‘--initial -i –initial initial tabs, convertingOnly convert initial tabs (those that precede all non-space or non-tabcharacters) on each line to spaces. An exit status of zero indicates success, and a nonzero value indicates failure. unexpand: Convert spaces to tabs unexpand unexpand writes the contents of each given file, or standard input if none are given or for a file of ‘-’, to standard output, converting blanks at the beginning of each line into as many tab characters as needed. In the default POSIX locale, a blank is a space or a tab; other locales may specify additional blank characters. Synopsis: unexpand [option]… [file]… By default, unexpand converts only initial blanks (those that precede all non-blank characters) on each line. It preserves backspace characters in the output; they decrement the column count for tab calculations. By default, tabs are set at every 8th column. The program accepts the following options. Also see . -t tab1[,tab2]…’‘--tabs=tab1[,tab2]… -t –tabsIf only one tab stop is given, set the tabs tab1 columns apartinstead of the default 8. Otherwise, set the tabs at columnstab1, tab2, … (numbered from 0), and leave blanksbeyond the tab stops given unchanged. Tab stops can be separated byblanks as well as by commas. This option implies the option.For compatibility, GNU unexpand supports the obsolete option syntax,, where tab stops must beseparated by commas. (Unlike , this obsolete option doesnot imply .) New scripts should use instead. -a’‘--all -a –allAlso convert all sequences of two or more blanks just before a tab stop,even if they occur after non-blank characters in a line. An exit status of zero indicates success, and a nonzero value indicates failure. Directory listing This chapter describes the ls command and its variants dir and vdir, which list information about files. ls: List directory contents ls directory listing The ls program lists information about files (of any type, including directories). Options and file arguments can be intermixed arbitrarily, as usual. For non-option command-line arguments that are directories, by default ls lists the contents of directories, not recursively, and omitting files with names beginning with ‘.’. For other non-option arguments, by default ls lists just the file name. If no non-option argument is specified, ls operates on the current directory, acting as if it had been invoked with a single argument of ‘.’. LC_ALL By default, the output is sorted alphabetically, according to the locale settings in effect.If you use a non-POSIX locale (e.g., by setting LC_ALL to ‘en_US’), then ls may produce output that is sorted differently than you're accustomed to. In that case, set the LC_ALL environment variable to ‘C’. If standard output is a terminal, the output is in columns (sorted vertically) and control characters are output as question marks; otherwise, the output is listed one per line and control characters are output as-is. Because ls is such a fundamental program, it has accumulated many options over the years. They are described in the subsections below; within each section, options are listed alphabetically (ignoring case). The division of options into the subsections is not absolute, since some options affect more than one aspect of ls's operation. exit status of ls Exit status: 0 success 1 minor problems (e.g., a subdirectory was not found) 2 serious trouble (e.g., memory exhausted) Also see . Which files are listed These options determine which files ls lists information for. By default, ls lists files and the contents of any directories on the command line, except that in directories it ignores files whose names start with ‘.’. -a’‘--all -a –allIn directories, do not ignore file names that start with ‘.’. -A’‘--almost-all -A –almost-allIn directories, do not ignore all file names that start with ‘.’;ignore only . and ... The ()option overrides this option. -B’‘--ignore-backups -B –ignore-backups backup files, ignoringIn directories, ignore files that end with ‘~’. This option isequivalent to ‘--ignore='*~' --ignore='.*~'’. -d’‘--directory -d –directoryList just the names of directories, as with other types of files, ratherthan listing their contents. Do not follow symbolic links listed on thecommand line unless the (), (), or options are specified. -H’‘--dereference-command-line -H –dereference-command-line symbolic links, dereferencingIf a command line argument specifies a symbolic link, show informationfor the file the link references rather than for the link itself. --dereference-command-line-symlink-to-dir –dereference-command-line-symlink-to-dir symbolic links, dereferencingDo not dereference symbolic links, with one exception:if a command line argument specifies a symbolic link that refers toa directory, show information for that directory rather than for thelink itself.This is the default behavior when no other dereferencing-relatedoption has been specified ( (), (),(), (), or ()). --group-directories-first –group-directories-firstGroup all the directories before the files and then sort thedirectories and the files separately using the selected sort key(see –sort option).That is, this option specifies a primary sort key,and the –sort option specifies a secondary key. --hide=PATTERN –hide=patternIn directories, ignore files whose names match the shell patternpattern, unless the () or () is also given. Thisoption acts like except that it has noeffect if () or () is also given.This option can be useful in shell aliases. For example, iflx is an alias for ‘ls --hide='*~'’ and ly isan alias for ‘ls --ignore='*~'’, then the command ‘lx -A’lists the file README~ even though ‘ly -A’ would not. -I pattern’‘--ignore=pattern -I –ignore=patternIn directories, ignore files whose names match the shell pattern(not regular expression) pattern. Asin the shell, an initial ‘.’ in a file name does not match awildcard at the start of pattern. Sometimes it is usefulto give this option several times. For example, $ ls --ignore='.??*' --ignore='.[^.]' --ignore='#*' The first option ignores names of length 3 or more that start with ‘.’,the second ignores all two-character names that start with ‘.’except ‘..’, and the third ignores names that start with ‘#’. -L’‘--dereference -L –dereference symbolic links, dereferencingWhen showing file information for a symbolic link, show informationfor the file the link references rather than the link itself.However, even with this option, ls still prints the nameof the link itself, not the name of the file that the link points to. -R’‘--recursive -R –recursive recursive directory listing directory listing, recursiveList the contents of all directories recursively. What information is listed These options affect the information that ls displays. By default, only file names are shown. --author –author hurd, author, printingList each file's author when producing long format directory listings.In GNU/Hurd, file authors can differ from their owners, but in otheroperating systems the two are the same. -D’‘--dired -D –dired dired Emacs mode supportWith the long listing () format, print an additional line afterthe main output: //DIRED// beg1 end1 beg2 end2The begN and endN are unsigned integers that record thebyte position of the beginning and end of each file name in the output.This makes it easy for Emacs to find the names, even when they containunusual characters such as space or newline, without fancy searching.If directories are being listed recursively (), output a similarline with offsets for each subdirectory name: //SUBDIRED// beg1 end1Finally, output a line of the form: //DIRED-OPTIONS// --quoting-style=word where word is the quoting style (see ).Here is an actual example: $ mkdir -p a/sub/deeper a/sub2 $ touch a/f1 a/f2 $ touch a/sub/deeper/file $ ls -gloRF --dired a a: total 8 -rw-r--r-- 1 0 Jun 10 12:27 f1 -rw-r--r-- 1 0 Jun 10 12:27 f2 drwxr-xr-x 3 4096 Jun 10 12:27 sub/ drwxr-xr-x 2 4096 Jun 10 12:27 sub2/ a/sub: total 4 drwxr-xr-x 2 4096 Jun 10 12:27 deeper/ a/sub/deeper: total 0 -rw-r--r-- 1 0 Jun 10 12:27 file a/sub2: total 0 //DIRED// 48 50 84 86 120 123 158 162 217 223 282 286 //SUBDIRED// 2 3 167 172 228 240 290 296 //DIRED-OPTIONS// --quoting-style=literal Note that the pairs of offsets on the ‘//DIRED//’ line above delimitthese names: f1, f2, sub, sub2, deeper,file.The offsets on the ‘//SUBDIRED//’ line delimit the followingdirectory names: a, a/sub, a/sub/deeper, a/sub2.Here is an example of how to extract the fifth entry name, ‘deeper’,corresponding to the pair of offsets, 222 and 228: $ ls -gloRF --dired a > out $ dd bs=1 skip=222 count=6 < out 2>/dev/null; echo deeper Note that although the listing above includes a trailing slashfor the ‘deeper’ entry, the offsets select the name withoutthe trailing slash. However, if you invoke ls with along with an option like (aka ) and operateon a file whose name contains special characters, notice that the backslashis included: $ touch 'a b' $ ls -blog --dired 'a b' -rw-r--r-- 1 0 Jun 10 12:28 a\ b //DIRED// 30 34 //DIRED-OPTIONS// --quoting-style=escape If you use a quoting style that adds quote marks(e.g., ), then the offsets include the quote marks.So beware that the user may select the quoting style via the environmentvariable QUOTING_STYLE. Hence, applications using should either specify an explicit option(aka or ) on the command line, or else beprepared to parse the escaped names. --full-time –full-timeProduce long format directory listings, and list times in full. It isequivalent to using with (see ). -g -gProduce long format directory listings, but don't display owner information. -G’‘--no-group -G –no-groupInhibit display of group information in a long format directory listing.(This is the default in some non-gnu versions of ls, so weprovide this option for compatibility.) -h’‘--human-readable -h –human-readable human-readable outputAppend a size letter to each size, such as ‘M’ for mebibytes.Powers of 1024 are used, not 1000; ‘M’ stands for 1,048,576 bytes.Use the option if you prefer powers of 1000. -i’‘--inode -i –inode inode number, printingPrint the inode number (also called the file serial number and indexnumber) of each file to the left of the file name. (This numberuniquely identifies each file within a particular file system.) -l’‘--format=long’‘--format=verbose -l –format long ls format verbose ls formatIn addition to the name of each file, print the file type, file mode bits,number of hard links, owner name, group name, size, andtimestamp (see ), normallythe modification time. Print question marks for information thatcannot be determined.Normally the size is printed as a byte count without punctuation, butthis can be overridden (see ). For example, prints an abbreviated, human-readable count, and‘--block-size="'1"’ prints a byte count with the thousandsseparator of the current locale.For each directory that is listed, preface the files with a line‘total blocks’, where blocks is the total disk allocationfor all files in that directory. The block size currently defaults to 1024bytes, but this can be overridden (see ).The blocks computed counts each hard link separately;this is arguably a deficiency.The file type is one of the following characters: -regular file bblock special file ccharacter special file Chigh performance (“contiguous data”) file ddirectory Ddoor (Solaris 2.5 and up) lsymbolic link Moff-line (“migrated”) file (Cray DMF) nnetwork special file (HP-UX) pFIFO (named pipe) Pport (Solaris 10 and up) ssocket ?some other file type permissions, output by lsThe file mode bits listed are similar to symbolic mode specifications(see ). But ls combines multiple bits into thethird character of each set of permissions as follows: sIf the set-user-ID or set-group-ID bit and the corresponding executable bitare both set. SIf the set-user-ID or set-group-ID bit is set but the correspondingexecutable bit is not set. tIf the restricted deletion flag or sticky bit, and theother-executable bit, are both set. The restricted deletion flag isanother name for the sticky bit. See . TIf the restricted deletion flag or sticky bit is set but theother-executable bit is not set. xIf the executable bit is set and none of the above apply. -Otherwise. Following the file mode bits is a single character that specifieswhether an alternate access method such as an access control listapplies to the file. When the character following the file mode bits is aspace, there is no alternate access method. When it is a printingcharacter, then there is such a method.For a file with an extended access control list, a ‘+’ character islisted. Basic access control lists are equivalent to the permissionslisted, and are not considered an alternate access method. -n’‘--numeric-uid-gid -n –numeric-uid-gid numeric uid and gid numeric user and group IDsProduce long format directory listings, butdisplay numeric user and group IDs instead of the owner and group names. -o -oProduce long format directory listings, but don't display group information.It is equivalent to using with . -s’‘--size -s –size disk allocation size of files, reportingPrint the disk allocation of each file to the left of the file name.This is the amount of disk space used by the file, which is usually abit more than the file's size, but it can be less if the file has holes.Normally the disk allocation is printed in units of1024 bytes, but this can be overridden (see ). NFS mounts from BSD to HP-UXFor files that are NFS-mounted from an HP-UX system to a BSD system,this option reports sizes that are half the correct values. On HP-UXsystems, it reports sizes that are twice the correct values for filesthat are NFS-mounted from BSD systems. This is due to a flaw in HP-UX;it also affects the HP-UX ls program. --si –si SI outputAppend an SI-style abbreviation to each size, such as ‘M’ formegabytes. Powers of 1000 are used, not 1024; ‘M’ stands for1,000,000 bytes. This option is equivalent to. Use the or option ifyou prefer powers of 1024. Sorting the output sorting ls output These options change the order in which ls sorts the information it outputs. By default, sorting is done by character code (e.g., ASCII order). -c’‘--time=ctime’‘--time=status -c –time ctime, printing or sorting by status time, printing or sorting by use time, printing or sorting files byIf the long listing format (e.g., , ) is being used,print the status change time (the ‘ctime’ in the inode) instead ofthe modification time.When explicitly sorting by time ( or )or when not using a long listing format,sort according to the status change time. -f -f unsorted directory listing directory order, listing byPrimarily, like —do not sort; list the files in whateverorder they are stored in the directory. But also enable (listall files) and disable , , and (if theywere specified before the ). -r’‘--reverse -r –reverse reverse sortingReverse whatever the sorting method is—e.g., list files in reversealphabetical order, youngest first, smallest first, or whatever. -S’‘--sort=size -S –sort size of files, sorting files bySort by file size, largest first. -t’‘--sort=time -t –sort modification time, sorting files bySort by modification time (the ‘mtime’ in the inode), newest first. -u’‘--time=atime’‘--time=access’‘--time=use -u –time use time, printing or sorting files by atime, printing or sorting files by access time, printing or sorting files byIf the long listing format (e.g., ) is being used,print the last access time (the ‘atime’ in the inode).When explicitly sorting by time ( or )or when not using a long listing format, sort according to the access time. -U’‘--sort=none -U –sort none, sorting option for lsDo not sort; list the files in whatever order they arestored in the directory. (Do not do any of the other unrelated thingsthat does.) This is especially useful when listing very largedirectories, since not doing any sorting can be noticeably faster. -v’‘--sort=version -v –sort version, sorting option for lsSort by version name and number, lowest first. It behaves like a defaultsort, except that each sequence of decimal digits is treated numericallyas an index/version number. (See .) -X’‘--sort=extension -X –sort extension, sorting files bySort directory contents alphabetically by file extension (charactersafter the last ‘.’); files with no extension are sorted first. More details about version sort The version sort takes into account the fact that file names frequently include indices or version numbers. Standard sorting functions usually do not produce the ordering that people expect because comparisons are made on a character-by-character basis. The version sort addresses this problem, and is especially useful when browsing directories that contain many files with indices/version numbers in their names: $ ls -1 $ ls -1v foo.zml-1.gz foo.zml-1.gz foo.zml-100.gz foo.zml-2.gz foo.zml-12.gz foo.zml-6.gz foo.zml-13.gz foo.zml-12.gz foo.zml-2.gz foo.zml-13.gz foo.zml-25.gz foo.zml-25.gz foo.zml-6.gz foo.zml-100.gz Note also that numeric parts with leading zeros are considered as fractional one: $ ls -1 $ ls -1v abc-1.007.tgz abc-1.007.tgz abc-1.012b.tgz abc-1.01a.tgz abc-1.01a.tgz abc-1.012b.tgz This functionality is implemented using the strverscmp function. See See section ``String/Array Comparison'' in The GNU C Library Reference Manual. One result of that implementation decision is that ls -v does not use the locale category, LC_COLLATE. As a result, non-numeric prefixes are sorted as if LC_COLLATE were set to C. General output formatting These options affect the appearance of the overall output. -1’‘--format=single-column -1 –format single-column output of filesList one file per line. This is the default for ls when standardoutput is not a terminal. -C’‘--format=vertical -C –format vertical sorted files in columnsList files in columns, sorted vertically. This is the default forls if standard output is a terminal. It is always the defaultfor the dir program.gnu ls uses variable width columns to display as many files aspossible in the fewest lines. --color [=when] –color color, distinguishing file types withSpecify whether to use color for distinguishing file types. whenmay be omitted, or one of: none none color option- Do not use color at all. This is the default. auto auto color option terminal, using color iff- Only use color if standard output is a terminal. always always color option- Always use color. Specifying and no when is equivalent to.Piping a colorized listing through a pager like more orless usually produces unreadable results. However, usingmore -f does seem to work. -F’‘--classify’‘--indicator-style=classify -F –classify –indicator-style file type and executables, marking executables and file type, markingAppend a character to each file name indicating the file type. Also,for regular files that are executable, append ‘*’. The file typeindicators are ‘/’ for directories, ‘@’ for symbolic links,‘|’ for FIFOs, ‘=’ for sockets, ‘>’ for doors,and nothing for regular files. Do not follow symbolic links listed on thecommand line unless the (), (), or options are specified. --file-type’‘--indicator-style=file-type –file-type –indicator-style file type, markingAppend a character to each file name indicating the file type. This islike , except that executables are not marked. --indicator-style=word –indicator-styleAppend a character indicator with style word to entry names,as follows: noneDo not append any character indicator; this is the default. slashAppend ‘/’ for directories. This is the same as the option. file-typeAppend ‘/’ for directories, ‘@’ for symbolic links, ‘|’for FIFOs, ‘=’ for sockets, and nothing for regular files. This isthe same as the option. classifyAppend ‘*’ for executable regular files, otherwise behave as for‘file-type’. This is the same as the or option. -k -kPrint file sizes in 1024-byte blocks, overriding the default blocksize (see ).This option is equivalent to . -m’‘--format=commas -m –format commas, outputting between filesList files horizontally, with as many as will fit on each line,separated by ‘, ’ (a comma and a space). -p’‘--indicator-style=slash -p –indicator-style file type, markingAppend a ‘/’ to directory names. -x’‘--format=across’‘--format=horizontal -x –format across, listing files horizontal, listing filesList the files in columns, sorted horizontally. -T cols’‘--tabsize=cols -T –tabsizeAssume that each tab stop is cols columns wide. The default is 8.ls uses tabs where possible in the output, for efficiency. Ifcols is zero, do not use tabs at all. 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 anon-ASCII byte. If you use such a terminal emulator, use the option or put TABSIZE=0 in your environment to tellls to align using spaces, not tabs. -w’‘--width=cols -w –width COLUMNSAssume the screen is cols columns wide. The default is takenfrom the terminal settings if possible; otherwise the environmentvariable COLUMNS is used if it is set; otherwise the defaultis 80. Formatting file timestamps By default, file timestamps are listed in abbreviated form. Most locales use a timestamp like ‘2002-03-30 23:45’. However, the default POSIX locale uses a date like ‘Mar 30 2002’ for non-recent timestamps, and a date-without-year and time like ‘Mar 30 23:45’ for recent timestamps. A timestamp is considered to be 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, which means you probably have clock skew problems which may break programs like make that rely on file timestamps. TZ Time stamps are listed according to the time zone rules specified by the TZ environment variable, or by the system default rules if TZ is not set. See See section ``Specifying the Time Zone with @env{TZ}'' in The GNU C Library. The following option changes how file timestamps are printed. --time-style=style –time-style time styleList timestamps in style style. The style shouldbe one of the following: +format LC_TIMEList timestamps using format, where format is interpretedlike the format argument of date (see ).For example, causesls to list timestamps like ‘2002-03-30 23:45:56’. Aswith date, format's interpretation is affected by theLC_TIME locale category.If format contains two format strings separated by a newline,the former is used for non-recent files and the latter for recentfiles; if you want output columns to line up, you may need to insertspaces in one of the two formats. full-isoList timestamps in full using ISO 8601 date, time, and time zoneformat with nanosecond precision, e.g., ‘2002-03-3023:45:56.477817180 -0700’. This style is equivalent to‘+%Y-%m-%d %H:%M:%S.%N %z’.This is useful because the time output includes all the information thatis available from the operating system. For example, this can helpexplain make's behavior, since GNU makeuses the full timestamp to determine whether a file is out of date. long-isoList ISO 8601 date and time in minutes, e.g.,‘2002-03-30 23:45’. These timestamps are shorter than‘full-iso’ timestamps, and are usually good enough for everydaywork. This style is equivalent to ‘+%Y-%m-%d %H:%M’. isoList ISO 8601 dates for non-recent timestamps (e.g.,‘2002-03-30 ’), and ISO 8601 month, day, hour, andminute for recent timestamps (e.g., ‘03-30 23:45’). Thesetimestamps are uglier than ‘long-iso’ timestamps, but they carrynearly the same information in a smaller space and their brevity helpsls output fit within traditional 80-column output lines.The following two ls invocations are equivalent: newline=' ' ls -l --time-style="+%Y-%m-%d $newline%m-%d %H:%M" ls -l --time-style="iso" locale LC_TIMEList timestamps in a locale-dependent form. For example, a Finnishlocale might list non-recent timestamps like ‘maalis 30 2002’and recent timestamps like ‘maalis 30 23:45’. Locale-dependenttimestamps typically consume more space than ‘iso’ timestamps andare harder for programs to parse because locale conventions vary sowidely, but they are easier for many people to read.The LC_TIME locale category specifies the timestamp format. Thedefault POSIX locale uses timestamps like ‘Mar 30 2002’ and ‘Mar 30 23:45’; in this locale, the following twols invocations are equivalent: newline=' ' ls -l --time-style="+%b %e %Y$newline%b %e %H:%M" ls -l --time-style="locale" Other locales behave differently. For example, in a German locale, might be equivalent toand might generate timestamps like ‘30. Mär 2002 ’ and‘30. Mär 23:45’. posix-style LC_TIMEList POSIX-locale timestamps if the LC_TIME localecategory is POSIX, style timestamps otherwise. Forexample, the ‘posix-long-iso’ style liststimestamps like ‘Mar 30 2002’ and ‘Mar 30 23:45’ when inthe POSIX locale, and like ‘2002-03-30 23:45’ otherwise. TIME_STYLE You can specify the default value of the option with the environment variable TIME_STYLE; if TIME_STYLE is not set the default style is ‘locale’. GNU Emacs 21.3 and later use the option and therefore can parse any date format, but if you are using Emacs 21.1 or 21.2 and specify a non-POSIX locale you may need to set ‘TIME_STYLE="posix-long-iso"’. To avoid certain denial-of-service attacks, timestamps that would be longer than 1000 bytes may be treated as errors. Formatting the file names These options change how file names themselves are printed. -b’‘--escape’‘--quoting-style=escape -b –escape –quoting-style backslash sequences for file namesQuote nongraphic characters in file names using alphabetic and octalbackslash sequences like those used in C. -N’‘--literal’‘--quoting-style=literal -N –literal –quoting-styleDo not quote file names. However, with ls nongraphiccharacters are still printed as question marks if the output is aterminal and you do not specify the option. -q’‘--hide-control-chars -q –hide-control-charsPrint question marks instead of nongraphic characters in file names.This is the default if the output is a terminal and the program isls. -Q’‘--quote-name’‘--quoting-style=c -Q –quote-name –quoting-styleEnclose file names in double quotes and quote nongraphic characters asin C. --quoting-style=word –quoting-style quoting styleUse style word to quote file names and other strings that maycontain arbitrary characters. The word shouldbe one of the following: literalOutput strings as-is; this is the same as the or option. shellQuote strings for the shell if they contain shell metacharacters or wouldcause ambiguous output.The quoting is suitable for POSIX-compatible shells likebash, but it does not always work for incompatible shellslike csh. shell-alwaysQuote strings for the shell, even if they would normally not require quoting. cQuote strings as for C character string literals, including thesurrounding double-quote characters; this is the same as the or option. escapeQuote strings as for C character string literals, except omit thesurrounding double-quotecharacters; this is the same as the or option. clocaleQuote strings as for C character string literals, except usesurrounding quotation marks appropriate for thelocale. locale Quote strings as for C character string literals, except usesurrounding quotation marks appropriate for the locale, and quote`like this' instead of "likethis" in the default C locale. This looks nicer on many displays. You can specify the default value of the optionwith the environment variable QUOTING_STYLE. If that environmentvariable is not set, the default value is ‘literal’, but thisdefault may change to ‘shell’ in a future version of this package. --show-control-chars –show-control-charsPrint nongraphic characters as-is in file names.This is the default unless the output is a terminal and the program isls. dir: Briefly list directory contents dir directory listing, brief dir is equivalent to ls -C -b; that is, by default files are listed in columns, sorted vertically, and special characters are represented by backslash escape sequences. See ls. vdir: Verbosely list directory contents vdir directory listing, verbose vdir is equivalent to ls -l -b; that is, by default files are listed in long format and special characters are represented by backslash escape sequences. dircolors: Color setup for ls dircolors color setup setup for color dircolors outputs a sequence of shell commands to set up the terminal for color output from ls (and dir, etc.). Typical usage: eval "`dircolors [option]… [file]`" If file is specified, dircolors reads it to determine which colors to use for which file types and extensions. Otherwise, a precompiled database is used. For details on the format of these files, run ‘dircolors --print-database’. LS_COLORS SHELL environment variable, and color The output is a shell command to set the LS_COLORS environment variable. You can specify the shell syntax to use on the command line, or dircolors will guess it from the value of the SHELL environment variable. The program accepts the following options. Also see . -b’‘--sh’‘--bourne-shell -b –sh –bourne-shell Bourne shell syntax for color setup sh syntax for color setupOutput Bourne shell commands. This is the default if the SHELLenvironment variable is set and does not end with ‘csh’ or‘tcsh’. -c’‘--csh’‘--c-shell -c –csh –c-shell C shell syntax for color setup csh syntax for color setupOutput C shell commands. This is the default if SHELL ends withcsh or tcsh. -p’‘--print-database -p –print-database color database, printing database for color setup, printing printing color databasePrint the (compiled-in) default color configuration database. Thisoutput is itself a valid configuration file, and is fairly descriptiveof the possibilities. An exit status of zero indicates success, and a nonzero value indicates failure. Basic operations manipulating files This chapter describes the commands for basic file manipulation: copying, moving (renaming), and deleting (removing). cp: Copy files and directories cp copying files and directories files, copying directories, copying cp copies files (or, optionally, directories). The copy is completely independent of the original. You can either copy one file to another, or copy arbitrarily many files to a destination directory. Synopses: cp [option]… [-T] source dest cp [option]… sourcedirectory cp [option]… -t directory source If two file names are given, cp copies the first file to thesecond. If the () option is given, orfailing that if the last file is a directory and the () option is not given,cp copies each source file to the specified directory,using the sources' names. Generally, files are written just as they are read. For exceptions, see the option below. By default, cp does not copy directories. However, the , , and options cause cp to copy recursively by descending into source directories and copying files to corresponding destination directories. By default, cp follows symbolic links only when not copying recursively. This default can be overridden with the (), , (), (), and options. If more than one of these options is specified, the last one silently overrides the others. By default, cp copies the contents of special files only when not copying recursively. This default can be overridden with the option. self-backups backups, making only cp generally refuses to copy a file onto itself, with the following exception: if is specified with source and dest identical, and referring to a regular file, cp will make a backup file, either regular or numbered, as specified in the usual ways (see ). This is useful when you simply want to make a backup of an existing file before changing it. The program accepts the following options. Also see . -a’‘--archive -a –archivePreserve as much as possible of the structure and attributes of theoriginal files in the copy (but do not attempt to preserve internaldirectory structure; i.e., ‘ls -U’ may list the entries in a copieddirectory in a different order).Equivalent to . -b’‘--backup[=method] -b –backup VERSION_CONTROL backups, makingSee .Make a backup of each file that would otherwise be overwritten or removed.As a special case, cp makes a backup of source when the forceand backup options are given and source and dest are the samename for an existing, regular file. One useful application of thiscombination of options is this tiny Bourne shell script: #!/bin/sh # Usage: backup FILE... # Create a gnu-style backup of each listed FILE. for i; do cp --backup --force -- "$i" "$i" done --copy-contents directories, copying recursively copying directories recursively recursively copying directories non-directories, copying as special filesIf copying recursively, copy the contents of any special files (e.g.,FIFOs and device files) as if they were regular files. This meanstrying to read the data in each source file and writing it to thedestination. It is usually a mistake to use this option, as itnormally has undesirable effects on special files like FIFOs and theones typically found in the /dev directory. In most cases,cp -R --copy-contents will hang indefinitely trying to readfrom FIFOs and special files like /dev/console, and it willfill up your destination disk if you use it to copy /dev/zero.This option has no effect unless copying recursively, and it does notaffect the copying of symbolic links. -d -d symbolic links, copying hard links, preservingCopy symbolic links as symbolic links rather than copying the files thatthey point to, and preserve hard links between source files in the copies.Equivalent to . -f’‘--force -f –forceWhen copying without this option and an existing destination file cannotbe opened for writing, the copy fails. However, with ),when a destination file cannot be opened, cp then unlinks it andtries to open it again. Contrast this behavior with that enabled by and , whereby the destination fileis never opened but rather is unlinked unconditionally. Also see thedescription of .This option is independent of the or option: neither cancels the effect of the other. -H -HIf a command line argument specifies a symbolic link, then copy thefile it points to rather than the symbolic link itself. However,copy (preserving its nature) any symbolic link that is encounteredvia recursive traversal. -i’‘--interactive -i –interactiveWhen copying a file other than a directory, prompt whether tooverwrite an existing destination file. -l’‘--link -l –linkMake hard links instead of copies of non-directories. -L’‘--dereference -L –dereferenceAlways follow symbolic links. -P’‘--no-dereference -P –no-dereference symbolic links, copyingCopy symbolic links as symbolic links rather than copying the files thatthey point to. -p’‘--preserve[=attribute_list] -p –preserve file information, preservingPreserve the specified attributes of the original files.If specified, the attribute_list must be a comma-separated listof one or more of the following strings: modePreserve the file mode bits and access control lists. ownershipPreserve the owner and group. On most modern systems,only users with appropriate privileges may change the owner of a file,and ordinary usersmay preserve the group ownership of a file only if they happen to bea member of the desired group. timestampsPreserve the times of last access and last modification, when possible.In general, it is not possible to preserve these attributeswhen the affected file is a symbolic link.However, FreeBSD now provides the lutimes function, which makesit possibile even for symbolic links. However, this implementation doesnot yet take advantage of that. linksPreserve in the destination filesany links between corresponding source files. allPreserve all file attributes.Equivalent to specifying all of the above. Using with no attribute_list is equivalentto .In the absence of this option, each destination file is created with themode bits of the corresponding source file, minus the bits set in theumask and minus the set-user-ID and set-group-ID bits.See . --no-preserve=attribute_list file information, preservingDo not preserve the specified attributes. The attribute_listhas the same form as for . --parents –parents parent directories and cpForm the name of each destination file by appending to the targetdirectory a slash and the specified name of the source file. The lastargument given to cp must be the name of an existing directory.For example, the command: cp --parents a/b/c existing_dir copies the file a/b/c to existing_dir/a/b/c, creatingany missing intermediate directories. --reply=how –reply interactivity Deprecated: to be removed in 2008.Using makes cp act as if ‘yes’ weregiven as a response to every prompt about a destination file. That effectivelycancels any preceding or option.Specify to make cp act as if ‘no’ weregiven as a response to every prompt about a destination file.Specify to make cp prompt the userabout each existing destination file. -R’‘-r’‘--recursive -R -r –recursive directories, copying recursively copying directories recursively recursively copying directories non-directories, copying as special filesCopy directories recursively. Symbolic links are not followed bydefault; see the (), , (), (), and options. Special files are copied bycreating a destination file of the same type as the source; see the option. It is not portable to use to copy symbolic links or special files. On somenon-gnu systems, implies the equivalent of and for historical reasons.Also, it is not portable to use to copy symbolic linksunless you also specify , as POSIX allowsimplementations that dereference symbolic links by default. --remove-destination –remove-destinationRemove each existing destination file before attempting to open it(contrast with above). --sparse=when –sparse=when sparse files, copying holes, copying files with read system call, and holesA sparse file contains holes—a sequence of zero bytes thatdoes not occupy any physical disk blocks; the ‘read’ system callreads these as zeros. This can both save considerable disk space andincrease speed, since many binary files contain lots of consecutive zerobytes. By default, cp detects holes in input source files via a crudeheuristic and makes the corresponding output file sparse as well.Only regular files may be sparse.The when value can be one of the following: autoThe default behavior: if the input file is sparse, attempt to makethe output file sparse, too. However, if an output file exists butrefers to a non-regular file, then do not attempt to make it sparse. alwaysFor each sufficiently long sequence of zero bytes in the input file,attempt to create a corresponding hole in the output file, even if theinput file does not appear to be sparse.This is useful when the input file resides on a file systemthat does not support sparse files(for example, ‘efs’ file systems in SGI IRIX 5.3 and earlier),but the output file is on a type of file system that does support them.Holes may be created only in regular files, so if the destination fileis of some other type, cp does not even try to make it sparse. neverNever make the output file sparse.This is useful in creating a file for use with the mkswap command,since such a file must not have any holes. --strip-trailing-slashes –strip-trailing-slashes stripping trailing slashesRemove any trailing slashes from each source argument.See . -s’‘--symbolic-link -s –symbolic-link symbolic links, copying withMake symbolic links instead of copies of non-directories. All sourcefile names must be absolute (starting with ‘/’) unless thedestination files are in the current directory. This option merelyresults in an error message on systems that do not support symbolic links. -S suffix’‘--suffix=suffix -S –suffixAppend suffix to each backup file made with .See . -t directory’‘--target-directory=directory -t –target-directory target directory destination directorySpecify the destination directory.See . -T’‘--no-target-directory -T –no-target-directory target directory destination directoryDo not treat the last operand specially when it is a directory or asymbolic link to a directory. See . -u’‘--update -u –update newer files, copying onlyDo not copy a non-directory that has an existing destination with thesame or newer modification time. If time stamps are being preserved,the comparison is to the source time stamp truncated to theresolutions of the destination file system and of the system callsused to update time stamps; this avoids duplicate work if several‘cp -pu’ commands are executed with the same source anddestination. -v’‘--verbose -v –verbosePrint the name of each file before copying it. -x’‘--one-file-system -x –one-file-system file systems, omitting copying to differentSkip subdirectories that are on different file systems from the one thatthe copy started on.However, mount point directories are copied. An exit status of zero indicates success, and a nonzero value indicates failure. dd: Convert and copy a file dd converting while copying a file dd copies a file (from standard input to standard output, by default) with a changeable I/O block size, while optionally performing conversions on it. Synopses: dd [operand]… dd option The only options are and . See . dd accepts the following operands. if=file ifRead from file instead of standard input. of=file ofWrite to file instead of standard output. Unless‘conv=notrunc’ is given, dd truncates file to zerobytes (or the size specified with ‘seek=’). ibs=bytes ibs block size of input input block sizeSet the input block size to bytes.This makes dd read bytes per block. obs=bytes obs block size of output output block sizeSet the output block size to bytes.This makes dd write bytes per block. bs=bytes bs block sizeSet both input and output block sizes to bytes.This makes dd read and write bytes per block,overriding any ‘ibs’ and ‘obs’ settings. cbs=bytes cbs block size of conversion conversion block size fixed-length records, converting to variable-length variable-length records, converting to fixed-lengthSet the conversion block size to bytes.When converting variable-length records to fixed-length ones() or the reverse (),use bytes as the fixed record length. skip=blocks skipSkip blocksibs’-byte blocks in the input file before copying. seek=blocks seekSkip blocksobs’-byte blocks in the output file before copying. count=blocks countCopy blocksibs’-byte blocks from the input file, insteadof everything until the end of the file. conv=conversion[,conversion]… convConvert the file as specified by the conversion argument(s).(No spaces around any comma(s).)Conversions: ascii ascii, converting toConvert EBCDIC to ASCII,using the conversion table specified by POSIX.This provides a 1:1 translation for all 256 bytes. ebcdic ebcdic, converting toConvert ASCII to EBCDIC.This is the inverse of the ‘ascii’ conversion. ibm alternate ebcdic, converting toConvert ASCII to alternate EBCDIC,using the alternate conversion table specified by POSIX.This is not a 1:1 translation, but reflects common historical practicefor ‘~’, ‘[’, and ‘]’.The ‘ascii’, ‘ebcdic’, and ‘ibm’ conversions aremutually exclusive. block block (space-padding)For each line in the input, output ‘cbs’ bytes, replacing theinput newline with a space and padding with spaces as necessary. unblock unblockReplace trailing spaces in each ‘cbs’-sized input block with anewline.The ‘block’ and ‘unblock’ conversions are mutually exclusive. lcase lcase, converting toChange uppercase letters to lowercase. ucase ucase, converting toChange lowercase letters to uppercase.The ‘lcase’ and ‘ucase’ conversions are mutually exclusive. swab swab (byte-swapping) byte-swappingSwap every pair of input bytes. gnu dd, unlike others, workswhen an odd number of bytes are read—the last byte is simply copied(since there is nothing to swap it with). noerror noerror read errors, ignoringContinue after read errors. nocreat nocreat creating output file, avoidingDo not create the output file; the output file must already exist. excl excl creating output file, requiringFail if the output file already exists; dd must create theoutput file itself.The ‘excl’ and ‘nocreat’ conversions are mutually exclusive. notrunc notrunc truncating output file, avoidingDo not truncate the output file. sync sync (padding with nulls)Pad every input block to size of ‘ibs’ with trailing zero bytes.When used with ‘block’ or ‘unblock’, pad with spaces instead ofzero bytes. fdatasync fdatasync synchronized data writes, before finishingSynchronize output data just before finishing. This forces a physicalwrite of output data. fsync fsync synchronized data and metadata writes, before finishingSynchronize output data and metadata just before finishing. Thisforces a physical write of output data and metadata. iflag=flag[,flag]… iflagAccess the input file using the flags specified by the flagargument(s). (No spaces around any comma(s).) oflag=flag[,flag]… oflagAccess the output file using the flags specified by the flagargument(s). (No spaces around any comma(s).)Here are the flags. Not every flag is supported on every operatingsystem. append append appending to the output fileWrite in append mode, so that even if some other process is writing tothis file, every dd write will append to the currentcontents of the file. This flag makes sense only for output.If you combine this flag with the ‘of=file’ operand,you should also specify ‘conv=notrunc’ unless you want theoutput file to be truncated before being appended to. direct direct direct I/OUse direct I/O for data, avoiding the buffer cache. directory directory directory I/OFail unless the file is a directory. Most operating systems do notallow I/O to a directory, so this flag has limited utility. dsync dsync synchronized data readsUse synchronized I/O for data. For the output file, this forces aphysical write of output data on each write. For the input file,this flag can matter when reading from a remote file that has beenwritten to synchronously by some other process. Metadata (e.g.,last-access and last-modified time) is not necessarily synchronized. sync sync synchronized data and metadata I/OUse synchronized I/O for both data and metadata. nonblock nonblock nonblocking I/OUse non-blocking I/O. noatime noatime access timeDo not update the file's access time.Some older file systems silently ignore this flag, so it is a goodidea to test it on your files before relying on it. noctty noctty controlling terminalDo not assign the file to be a controlling terminal for dd.This has no effect when the file is not a terminal.On many hosts (e.g., GNU/Linux hosts), this option has no effectat all. nofollow nofollow symbolic links, followingDo not follow symbolic links. nolinks nolinks hard linksFail if the file has multiple hard links. binary binary binary I/OUse binary I/O. This option has an effect only on nonstandardplatforms that distinguish binary from text I/O. text text text I/OUse text I/O. Like ‘binary’, this option has no effect onstandard platforms. These flags are not supported on all systems, and ‘dd’ rejectsattempts to use them when they are not supported. When reading fromstandard input or writing to standard output, the ‘nofollow’ and‘noctty’ flags should not be specified, and the other flags(e.g., ‘nonblock’) can affect how other processes behave with theaffected file descriptors, even after dd exits. multipliers after numbers The numeric-valued strings above (bytes and blocks) can be followed by a multiplier: ‘b’=512, ‘c’=1, ‘w’=2, ‘xm’=m, or any of the standard block size suffixes like ‘k’=1024 (see ). Use different 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: disk=/dev/rdsk/c0t1d0s2 tape=/dev/rmt/0 # Copy all but the label from disk to tape. (dd bs=4k skip=1 count=0 && dd bs=512k) <$disk >$tape # Copy from tape back to disk, but leave the disk label alone. (dd bs=4k seek=1 count=0 && dd bs=512k) <$tape >$disk Sending an ‘INFO’ signal to a running dd process makes it print I/O statistics to standard error and then resume copying. In the example below, dd is run in the background to copy 10 million blocks. The kill command makes it output intermediate I/O statistics, and when dd completes, it outputs the final statistics. $ dd if=/dev/zero of=/dev/null count=10MB & pid=$! $ kill -s INFO $pid; wait $pid 3385223+0 records in 3385223+0 records out 1733234176 bytes (1.7 GB) copied, 6.42173 seconds, 270 MB/s 10000000+0 records in 10000000+0 records out 5120000000 bytes (5.1 GB) copied, 18.913 seconds, 271 MB/s POSIXLY_CORRECT On systems lacking the ‘INFO’ signal dd responds to the ‘USR1’ signal instead, unless the POSIXLY_CORRECT environment variable is set. An exit status of zero indicates success, and a nonzero value indicates failure. install: Copy files and set attributes install copying files and setting attributes install copies files while setting their file mode bits and, if possible, their owner and group. Synopses: install [option]… [-T] source dest install [option]… sourcedirectory install [option]… -t directory source… install [option]… -d directory If two file names are given, install copies the first file to thesecond. If the () option is given, orfailing that if the last file is a directory and the () option is not given,install copies each source file to the specifieddirectory, using the sources' names. If the () option is given,install creates each directory and any missing parentdirectories. Parent directories are created with mode‘u=rwx,go=rx’ (755), regardless of the option or thecurrent umask. See , for how theset-user-ID and set-group-ID bits of parent directories are inherited. Makefiles, installing programs in install is similar to cp, but allows you to control the attributes of destination files. It is typically used in Makefiles to copy programs into their destination directories. It refuses to copy files onto themselves. The program accepts the following options. Also see . -b’‘--backup[=method] -b –backup VERSION_CONTROL backups, makingSee .Make a backup of each file that would otherwise be overwritten or removed. -c -cIgnored; for compatibility with old Unix versions of install. -d’‘--directory -d –directory directories, creating with given attributes parent directories, creating missing leading directories, creating missingCreate any missing parent directories, giving them the defaultattributes. Then create each given directory, setting their owner,group and mode as given on the command line or to the defaults. -g group’‘--group=group -g –group group ownership of installed files, settingSet the group ownership of installed files or directories togroup. The default is the process's current group. groupmay be either a group name or a numeric group ID. -m mode’‘--mode=mode -m –mode permissions of installed files, settingSet the file mode bits for the installed file or directory to mode,which can be either an octal number, or a symbolic mode as inchmod, with ‘a=’ (no access allowed to anyone) as thepoint of departure (see ).The default mode is ‘u=rwx,go=rx,a-s’—read, write, andexecute for the owner, read and execute for group and other, and withset-user-ID and set-group-ID disabled.This default is not quite the same as ‘755’, since it disablesinstead of preserving set-user-ID and set-group-ID on directories.See . -o owner’‘--owner=owner -o –owner ownership of installed files, setting appropriate privileges root as default ownerIf install has appropriate privileges (is run as root), set theownership of installed files or directories to owner. The defaultis root. owner may be either a user name or a numeric userID. -p’‘--preserve-timestamps -p –preserve-timestamps timestamps of installed files, preservingSet the time of last access and the time of last modification of eachinstalled file to match those of each corresponding original file.When a file is installed without this option, its last access andlast modification times are both set to the time of installation.This option is useful if you want to use the last modification timesof installed files to keep track of when they were last built as opposedto when they were last installed. -s’‘--strip -s –strip symbol table information, stripping stripping symbol table informationStrip the symbol tables from installed binary executables. -S suffix’‘--suffix=suffix -S –suffixAppend suffix to each backup file made with .See . -t directory’‘--target-directory=directory -t –target-directory target directory destination directorySpecify the destination directory.See . -T’‘--no-target-directory -T –no-target-directory target directory destination directoryDo not treat the last operand specially when it is a directory or asymbolic link to a directory. See . -v’‘--verbose -v –verbosePrint the name of each file before copying it. An exit status of zero indicates success, and a nonzero value indicates failure. mv: Move (rename) files mv mv moves or renames files (or directories). Synopses: mv [option]… [-T] source dest mv [option]… sourcedirectory mv [option]… -t directory source If two file names are given, mv moves the first file to thesecond. If the () option is given, orfailing that if the last file is a directory and the () option is not given,mv moves each source file to the specifieddirectory, using the sources' names. mv can move any type of file from one file system to another. Prior to version 4.0 of the fileutils, mv could move only regular files between file systems. For example, now mv can move an entire directory hierarchy including special device files from one partition to another. It first uses some of the same code that's used by cp -a to copy the requested directories and files, then (assuming the copy succeeded) it removes the originals. If the copy fails, then the part that was copied to the destination partition is removed. If you were to copy three directories from one partition to another and the copy of the first directory succeeded, but the second didn't, the first would be left on the destination partition and the second and third would be left on the original partition. prompting, and mv If a destination file exists but is normally unwritable, standard input is a terminal, and the or option is not given, mv prompts the user for whether to replace the file. (You might own the file, or have write permission on its directory.) If the response is not affirmative, the file is skipped. Warning: If you try to move a symlink that points to a directory, and you specify the symlink with a trailing slash, then mv doesn't move the symlink but instead moves the directory referenced by the symlink. See . The program accepts the following options. Also see . -b’‘--backup[=method] -b –backup VERSION_CONTROL backups, makingSee .Make a backup of each file that would otherwise be overwritten or removed. -f’‘--force -f –force prompts, omittingDo not prompt the user before removing a destination file. -i’‘--interactive -i –interactive prompts, forcingPrompt whether to overwrite each existing destination file, regardlessof its permissions.If the response is not affirmative, the file is skipped. --reply=how –reply interactivity Deprecated: to be removed in 2008.Specifying is equivalent to using .Specify to make mv act as if ‘no’ weregiven as a response to every prompt about a destination file.Specify to make mv prompt the userabout each existing destination file.Note that has an effect only when mv would promptwithout or equivalent, i.e., when a destination file exists and isnot writable, standard input is a terminal, and no (or equivalent)option is specified. -u’‘--update -u –update newer files, moving onlyDo not move a non-directory that has an existing destination with thesame or newer modification time.If the move is across file system boundaries, the comparison is to thesource time stamp truncated to the resolutions of the destination filesystem and of the system calls used to update time stamps; this avoidsduplicate work if several ‘mv -u’ commands are executed with thesame source and destination. -v’‘--verbose -v –verbosePrint the name of each file before moving it. --strip-trailing-slashes –strip-trailing-slashes stripping trailing slashesRemove any trailing slashes from each source argument.See . -S suffix’‘--suffix=suffix -S –suffixAppend suffix to each backup file made with .See . -t directory’‘--target-directory=directory -t –target-directory target directory destination directorySpecify the destination directory.See . -T’‘--no-target-directory -T –no-target-directory target directory destination directoryDo not treat the last operand specially when it is a directory or asymbolic link to a directory. See . An exit status of zero indicates success, and a nonzero value indicates failure. rm: Remove files or directories rm removing files or directories rm removes each given file. By default, it does not remove directories. Synopsis: rm [option]… [file]… prompting, and rm If the or option is given, and there are more than three files or the , , or are given, then rm prompts the user for whether to proceed with the entire operation. If the response is not affirmative, the entire command is aborted. Otherwise, if a file is unwritable, standard input is a terminal, and the or option is not given, or the or option is given, rm prompts the user for whether to remove the file. If the response is not affirmative, the file is skipped. Any attempt to remove a file whose last file name component is . or .. is rejected without any prompting. Warning: If you use rm to remove a file, it is usually possible to recover the contents of that file. If you want more assurance that the contents are truly unrecoverable, consider using shred. The program accepts the following options. Also see . -f’‘--force -f –forceIgnore nonexistent files and never prompt the user.Ignore any previous () option. -i -iPrompt whether to remove each file.If the response is not affirmative, the file is skipped.Ignore any previous () option.Equivalent to . -I -IPrompt once whether to proceed with the command, if more than threefiles are named or if a recursive removal is requested. Ignore anyprevious () option. Equivalent to. --interactive [=when] –interactiveSpecify when to issue an interactive prompt. when may beomitted, or one of: never never interactive option- Do not prompt at all. once once interactive option- Prompt once if more than three files are named or if a recursiveremoval is requested. Equivalent to . always always interactive option- Prompt for every file being removed. Equivalent to . Specifying and no when is equivalent to. --one-file-system –one-file-system one file system, restricting rm toWhen removing a hierarchy recursively, skip any directory that is on afile system different from that of the corresponding command line argument.This option is useful when removing a build “chroot” hierarchy,which normally contains no valuable data. However, it is not uncommonto bind-mount /home into such a hierarchy, to make it easier touse one's start-up file. The catch is that it's easy to forget tounmount /home. Then, when you use rm -rf to removeyour normally throw-away chroot, that command will remove everythingunder /home, too.Use the option, and it willwarn about and skip directories on other file systems.Of course, this will not save your /home if it and yourchroot happen to be on the same file system. --preserve-root –preserve-root root directory, disallow recursive destructionFail upon any attempt to remove the root directory, /,when used with the option.This is the default behavior.See . --no-preserve-root –no-preserve-root root directory, allow recursive destructionDo not treat / specially when removing recursively.This option is not recommended unless you really want toremove all the files on your computer.See . -r’‘-R’‘--recursive -r -R –recursive directories, removing (recursively)Remove the listed directories and their contents recursively. -v’‘--verbose -v –verbosePrint the name of each file before removing it. files beginning with ‘-’, removing -’, removing files beginning with One common question is how to remove files whose names begin with a ‘-’. gnu rm, like every program that uses the getopt function to parse its arguments, lets you use the ‘--’ option to indicate that all following arguments are non-options. To remove a file called -f in the current directory, you could type either: rm -- -f or: rm ./-f - and Unix rm The Unix rm program's use of a single ‘-’ for this purpose predates the development of the getopt standard syntax. An exit status of zero indicates success, and a nonzero value indicates failure. shred: Remove files more securely shred data, erasing erasing data shred overwrites devices or files, to help prevent even very expensive hardware from recovering the data. Ordinarily when you remove a file (see ), the data is not actually destroyed. Only the index listing where the file is stored is destroyed, and the storage is made available for reuse. There are undelete utilities that will attempt to reconstruct the index and can bring the file back if the parts were not reused. On a busy system with a nearly-full drive, space can get reused in a few seconds. But there is no way to know for sure. If you have sensitive data, you may want to be sure that recovery is not possible by actually overwriting the file with non-sensitive data. However, even after doing that, it is possible to take the disk back to a laboratory and use a lot of sensitive (and expensive) equipment to look for the faint “echoes” of the original data underneath the overwritten data. If the data has only been overwritten once, it's not even that hard. The best way to remove something irretrievably is to destroy the media it's on with acid, melt it down, or the like. For cheap removable media like floppy disks, this is the preferred method. However, hard drives are expensive and hard to melt, so the shred utility tries to achieve a similar effect non-destructively. This uses many overwrite passes, with the data patterns chosen to maximize the damage they do to the old data. While this will work on floppies, the patterns are designed for best effect on hard drives. For more details, see the source code and Peter Gutmann's paper Secure Deletion of Data from Magnetic and Solid-State Memory, from the proceedings of the Sixth USENIX Security Symposium (San Jose, California, July 22–25, 1996). Please note that shred relies on a very important assumption: that the file system overwrites data in place. This is the traditional way to do things, but many modern file system designs do not satisfy this assumption. Exceptions include: Log-structured or journaled file systems, such as those supplied withAIX and Solaris, and JFS, ReiserFS, XFS, Ext3 (in data=journal mode),BFS, NTFS, etc. when they are configured to journal data. File systems that write redundant data and carry on even if some writesfail, such as RAID-based file systems. File systems that make snapshots, such as Network Appliance's NFS server. File systems that cache in temporary locations, such as NFS version 3clients. Compressed file systems. In the particular case of ext3 file systems, the above disclaimer applies (and shred is thus of limited effectiveness) only in data=journal mode, which journals file data in addition to just metadata. In both the data=ordered (default) and data=writeback modes, shred works as usual. Ext3 journaling modes can be changed by adding the data=something option to the mount options for a particular file system in the /etc/fstab file, as documented in the mount man page (man mount). If you are not sure how your file system operates, then you should assume that it does not overwrite data in place, which means that shred cannot reliably operate on regular files in your file system. Generally speaking, it is more reliable to shred a device than a file, since this bypasses the problem of file system design mentioned above. However, even shredding devices is not always completely reliable. For example, most disks map out bad sectors invisibly to the application; if the bad sectors contain sensitive data, shred won't be able to destroy it. shred makes no attempt to detect or report this problem, just as it makes no attempt to do anything about backups. However, since it is more reliable to shred devices than files, shred by default does not truncate or remove the output file. This default is more suitable for devices, which typically cannot be truncated and should not be removed. Finally, consider the risk of backups and mirrors. File system backups and remote mirrors may contain copies of the file that cannot be removed, and that will allow a shredded file to be recovered later. So if you keep any data you may later want to destroy using shred, be sure that it is not backed up or mirrored. shred [option]… file[…] The program accepts the following options. Also see . -f’‘--force -f –force force deletionOverride file permissions if necessary to allow overwriting. -NUMBER’‘-n NUMBER’‘--iterations=NUMBER -n NUMBER –iterations=NUMBER iterations, selecting the number ofBy default, shred uses 25 passes of overwrite. This is enoughfor all of the useful overwrite patterns to be used at least once.You can reduce this to save time, or increase it if you have a lot oftime to waste. --random-source=file –random-source random source for shreddingUse file as a source of random data used to overwrite and tochoose pass ordering. See . -s BYTES’‘--size=BYTES -s BYTES –size=BYTES size of file to shredShred the first BYTES bytes of the file. The default is to shredthe whole file. BYTES can be followed by a size specification like‘K’, ‘M’, or ‘G’ to specify a multiple. See . -u’‘--remove -u –remove removing files after shreddingAfter shredding a file, truncate it (if possible) and then remove it.If a file has multiple links, only the named links will be removed. -v’‘--verbose -v –verboseDisplay status updates as sterilization proceeds. -x’‘--exact -x –exactBy default, shred rounds the size of a regular file up to the nextmultiple of the file system block size to fully erase the last block of the file.Use to suppress that behavior.Thus, by default if you shred a 10-byte regular file on a system with 512-byteblocks, the resulting file will be 512 bytes long. With this option,shred does not increase the apparent size of the file. -z’‘--zero -z –zeroNormally, the last pass that shred writes is made up ofrandom data. If this would be conspicuous on your hard drive (forexample, because it looks like encrypted data), or you just thinkit's tidier, the option adds an additional overwrite pass withall zero bits. This is in addition to the number of passes specifiedby the option. You might use the following command to erase all trace of the file system you'd created on the floppy disk in your first drive. That command takes about 20 minutes to erase a “1.44MB” (actually 1440 KiB) floppy. shred --verbose /dev/fd0 Similarly, to erase all data on a selected partition of your hard disk, you could give a command like this: shred --verbose /dev/sda5 A file of ‘-’ denotes standard output. The intended use of this is to shred a removed temporary file. For example: i=`tempfile -m 0600` exec 3<>"$i" rm -- "$i" echo "Hello, world" >&3 shred - >&3 exec 3>- However, the command ‘shred - >file’ does not shred the contents of file, since the shell truncates file before invoking shred. Use the command ‘shred file’ or (if using a Bourne-compatible shell) the command ‘shred - 1<>file’ instead. An exit status of zero indicates success, and a nonzero value indicates failure. Special file types special file types file types, special This chapter describes commands which create special types of files (and rmdir, which removes directories, one special file type). special file types file types Although Unix-like operating systems have markedly fewer special file types than others, not everything can be treated only as the undifferentiated byte stream of normal files. For example, when a file is created or removed, the system must record this information, which it does in a directory—a special type of file. Although you can read directories as normal files, if you're curious, in order for the system to do its job it must impose a structure, a certain order, on the bytes of the file. Thus it is a “special” type of file. Besides directories, other special file types include named pipes (FIFOs), symbolic links, sockets, and so-called special files. link: Make a hard link via the link syscall link links, creating hard links, creating creating links (hard only) link creates a single hard link at a time. It is a minimalist interface to the system-provided link function. See See section ``Hard Links'' in The GNU C Library Reference Manual. It avoids the bells and whistles of the more commonly-used ln command (see ). Synopsis: link filename linkname filename must specify an existing file, and linkname must specify a nonexistent entry in an existing directory. link simply calls link (filename, linkname) to create the link. On a GNU system, this command acts like ‘ln --directory --no-target-directory filename linkname’. However, the and options are not specified by POSIX, and the link command is more portable in practice. An exit status of zero indicates success, and a nonzero value indicates failure. ln: Make links between files ln links, creating hard links, creating symbolic (soft) links, creating creating links (hard or soft) file systems and hard links ln makes links between files. By default, it makes hard links; with the option, it makes symbolic (or soft) links. Synopses: ln [option]… [-T] target linkname ln [option]… target ln [option]… targetdirectory ln [option]… -t directory target If two file names are given, ln creates a link to the firstfile from the second. If one target is given, ln creates a link to that filein the current directory. If the () option is given, orfailing that if the last file is a directory and the () option is not given,ln creates a link to each target file in the specifieddirectory, using the targets' names. Normally ln does not remove existing files. Use the () option to remove them unconditionally, the () option to remove them conditionally, and the () option to rename them. hard link, defined inode, and hard links A hard link is another name for an existing file; the link and the original are indistinguishable. Technically speaking, they share the same inode, and the inode contains all the information about a file—indeed, it is not incorrect to say that the inode is the file. On all existing implementations, you cannot make a hard link to a directory, and hard links cannot cross file system boundaries. (These restrictions are not mandated by POSIX, however.) dereferencing symbolic links symbolic link, defined Symbolic links (symlinks for short), on the other hand, are a special file type (which not all kernels support: System V release 3 (and older) systems lack symlinks) in which the link file actually refers to a different file, by name. When most operations (opening, reading, writing, and so on) are passed the symbolic link file, the kernel automatically dereferences the link and operates on the target of the link. But some operations (e.g., removing) work on the link file itself, rather than on its target. See See section ``Symbolic Links'' in The GNU C Library Reference Manual. The program accepts the following options. Also see . -b’‘--backup[=method] -b –backup VERSION_CONTROL backups, makingSee .Make a backup of each file that would otherwise be overwritten or removed. -d’‘-F’‘--directory -d -F –directory hard links to directoriesAllow users with appropriate privileges to attempt to make hard linksto directories.However, note that this will probably fail due tosystem restrictions, even for the super-user. -f’‘--force -f –forceRemove existing destination files. -i’‘--interactive -i –interactive prompting, and lnPrompt whether to remove existing destination files. -n’‘--no-dereference -n –no-dereferenceDo not treat the last operand specially when it is a symbolic link toa directory. Instead, treat it as if it were a normal file.When the destination is an actual directory (not a symlink to one),there is no ambiguity. The link is created in that directory.But when the specified destination is a symlink to a directory,there are two ways to treat the user's request. ln cantreat the destination just as it would a normal directory and createthe link in it. On the other hand, the destination can be viewed as anon-directory—as the symlink itself. In that case, lnmust delete or backup that symlink before creating the new link.The default is to treat a destination that is a symlink to a directoryjust like a directory.This option is weaker than the () option, so it has no effect if both options are given. -s’‘--symbolic -s –symbolicMake symbolic links instead of hard links. This option merely producesan error message on systems that do not support symbolic links. -S suffix’‘--suffix=suffix -S –suffixAppend suffix to each backup file made with .See . -t directory’‘--target-directory=directory -t –target-directory target directory destination directorySpecify the destination directory.See . -T’‘--no-target-directory -T –no-target-directory target directory destination directoryDo not treat the last operand specially when it is a directory or asymbolic link to a directory. See . -v’‘--verbose -v –verbosePrint the name of each file after linking it successfully. An exit status of zero indicates success, and a nonzero value indicates failure. Examples: Bad Example: # Create link ../a pointing to a in that directory. # Not really useful because it points to itself. ln -s a .. Better Example: # Change to the target before creating symlinks to avoid being confused. cd .. ln -s adir/a . Bad Example: # Hard coded file names don't move well. ln -s $(pwd)/a /some/dir/ Better Example: # Relative file names survive directory moves and also # work across networked file systems. ln -s afile anotherfile ln -s ../adir/afile yetanotherfile mkdir: Make directories mkdir directories, creating creating directories mkdir creates directories with the specified names. Synopsis: mkdir [option]… name mkdir creates each directory name in the order given. It reports an error if name already exists, unless the option is given and name is a directory. The program accepts the following options. Also see . -m mode’‘--mode=mode -m –mode modes of created directories, settingSet the file permission bits of created directories to mode,which uses the same syntax asin chmod and uses ‘a=rwx’ (read, write and execute allowed foreveryone) for the point of the departure. See .Normally the directory has the desired file mode bits at the moment itis created. As a GNU extension, mode may also mentionspecial mode bits, but in this case there may be a temporary windowduring which the directory exists but its special mode bits areincorrect. See , for how theset-user-ID and set-group-ID bits of directories are inherited unlessoverridden in this way. -p’‘--parents -p –parents parent directories, creatingMake any missing parent directories for each argument, setting theirfile permission bits to the umask modified by ‘u+wx’. Ignoreexisting parent directories, and do not change their file permissionbits.To set the file permission bits of any newly-created parentdirectories to a value that includes ‘u+wx’, you can set theumask before invoking mkdir. For example, if the shellcommand ‘(umask u=rwx,go=rx; mkdir -p P/Q)’ creates the parentP it sets the parent's permission bits to ‘u=rwx,go=rx’.To set a parent's special mode bits as well, you can invokechmod after mkdir. See , for how the set-user-ID and set-group-ID bits ofnewly-created parent directories are inherited. -v’‘--verbose -v –verbosePrint a message for each created directory. This is most useful with. An exit status of zero indicates success, and a nonzero value indicates failure. mkfifo: Make FIFOs (named pipes) mkfifo FIFOs, creating named pipes, creating creating FIFOs (named pipes) mkfifo creates FIFOs (also called named pipes) with the specified names. Synopsis: mkfifo [option] name A FIFO is a special file type that permits independent processes to communicate. One process opens the FIFO file for writing, and another for reading, after which data can flow as with the usual anonymous pipe in shells or elsewhere. The program accepts the following option. Also see . -m mode’‘--mode=mode -m –mode modes of created FIFOs, settingSet the mode of created FIFOs to mode, which is symbolic as inchmod and uses ‘a=rw’ (read and write allowed for everyone)for the point of departure. mode should specify only filepermission bits. See . An exit status of zero indicates success, and a nonzero value indicates failure. mknod: Make block or character special files mknod block special files, creating character special files, creating mknod creates a FIFO, character special file, or block special file with the specified name. Synopsis: mknod [option]… name type [major minor] special files block special files character special files Unlike the phrase “special file type” above, the term special file has a technical meaning on Unix: something that can generate or receive data. Usually this corresponds to a physical piece of hardware, e.g., a printer or a disk. (These files are typically created at system-configuration time.) The mknod command is what creates files of this type. Such devices can be read either a character at a time or a “block” (many characters) at a time, hence we say there are block special files and character special files. The arguments after name specify the type of file to make: p p for FIFO filefor a FIFO b b for block special filefor a block special file c c for character special file for a character special file When making a block or character special file, the major and minor device numbers must be given after the file type. If a major or minor device number begins with ‘0x’ or ‘0X’, it is interpreted as hexadecimal; otherwise, if it begins with ‘0’, as octal; otherwise, as decimal. The program accepts the following option. Also see . -m mode’‘--mode=mode -m –modeSet the mode of created files to mode, which is symbolic as inchmod and uses ‘a=rw’ as the point of departure.mode should specify only file permission bits.See . An exit status of zero indicates success, and a nonzero value indicates failure. readlink: Print the referent of a symbolic link readlink displaying value of a symbolic link readlink may work in one of two supported modes: Readlink modereadlink outputs the value of the given symbolic link.If readlink is invoked with an argument other than the nameof a symbolic link, it produces no output and exits with a nonzero exit code. Canonicalize modereadlink outputs the absolute name of the given file which containsno ., .. components nor any repeated separators(/) or symbolic links. readlink [option] file By default, readlink operates in readlink mode. The program accepts the following options. Also see . -f’‘--canonicalize -f –canonicalizeActivate canonicalize mode.If any component of the file name except the last one is missing or unavailable,readlink produces no output and exits with a nonzero exit code. -e’‘--canonicalize-existing -e –canonicalize-existingActivate canonicalize mode.If any component is missing or unavailable, readlink producesno output and exits with a nonzero exit code. -m’‘--canonicalize-missing -m –canonicalize-missingActivate canonicalize mode.If any component is missing or unavailable, readlink treats itas a directory. -n’‘--no-newline -n –no-newlineDo not output the trailing newline. -s’‘-q’‘--silent’‘--quiet -s -q –silent –quietSuppress most error messages. -v’‘--verbose -v –verboseReport error messages. The readlink utility first appeared in OpenBSD 2.1. An exit status of zero indicates success, and a nonzero value indicates failure. rmdir: Remove empty directories rmdir removing empty directories directories, removing empty rmdir removes empty directories. Synopsis: rmdir [option]… directory If any directory argument does not refer to an existing empty directory, it is an error. The program accepts the following option. Also see . --ignore-fail-on-non-empty –ignore-fail-on-non-empty directory deletion, ignoring failuresIgnore each failure to remove a directory that is solely becausethe directory is non-empty. -p’‘--parents -p –parents parent directories, removingRemove directory, then try to remove each component of directory.So, for example, ‘rmdir -p a/b/c’ is similar to ‘rmdir a/b/c a/b a’.As such, it fails if any of those directories turns out not to be empty.Use the option to make it so sucha failure does not evoke a diagnostic and does not cause rmdir toexit unsuccessfully. -v’‘--verbose -v –verbose directory deletion, reportingGive a diagnostic for each successful removal.directory is removed. See , for how to remove non-empty directories (recursively). An exit status of zero indicates success, and a nonzero value indicates failure. unlink: Remove files via the unlink syscall unlink removing files or directories (via the unlink syscall) unlink deletes a single specified file name. It is a minimalist interface to the system-provided unlink function. See See section ``Deleting Files'' in The GNU C Library Reference Manual. Synopsis: It avoids the bells and whistles of the more commonly-used rm command (see ). unlink filename On some systems unlink can be used to delete the name of a directory. On others, it can be used that way only by a privileged user. In the GNU system unlink can never delete the name of a directory. The unlink command honors the and options. To remove a file whose name begins with ‘-’, prefix the name with ‘./’, e.g., ‘unlink ./--help’. An exit status of zero indicates success, and a nonzero value indicates failure. Changing file attributes changing file attributes file attributes, changing attributes, file A file is not merely its contents, a name, and a file type (see ). A file also has an owner (a user ID), a group (a group ID), permissions (what the owner can do with the file, what people in the group can do, and what everyone else can do), various timestamps, and other information. Collectively, we call these a file's attributes. These commands change file attributes. chown: Change file owner and group chown file ownership, changing group ownership, changing changing file ownership changing group ownership chown changes the user and/or group ownership of each given file to new-owner or to the user and group of an existing reference file. Synopsis: chown [option]… {new-owner | --reference=ref_file} file If used, new-owner specifies the new owner and/or group as follows (with no embedded white space): [owner] [ : [group] ] Specifically: owner If only an owner (a user name or numeric user ID) is given, thatuser is made the owner of each given file, and the files' group is notchanged. owner‘:’group If the owner is followed by a colon and a group (agroup name or numeric group ID), with no spaces between them, the groupownership of the files is changed as well (to group). owner‘:’ If a colon but no group name follows owner, that user ismade the owner of the files and the group of the files is changed toowner's login group. ‘:’group If the colon and following group are given, but the owneris omitted, only the group of the files is changed; in this case,chown performs the same function as chgrp. ‘:’ If only a colon is given, or if new-owner is empty, neither theowner nor the group is changed. If owner or group is intended to represent a numeric user or group ID, then you may specify it with a leading ‘+’. See . Some older scripts may still use ‘.’ in place of the ‘:’ separator. POSIX 1003.1-2001 (see ) does not require support for that, but for backward compatibility GNU chown supports ‘.’ so long as no ambiguity results. New scripts should avoid the use of ‘.’ because it is not portable, and because it has undesirable results if the entire owner‘.’group happens to identify a user whose name contains ‘.’. The chown command sometimes clears the set-user-ID or set-group-ID permission bits. This behavior depends on the policy and functionality of the underlying chown system call, which may make system-dependent file mode modifications outside the control of the chown command. For example, the chown command might not affect those bits when invoked by a user with appropriate privileges, or when the bits signify some function other than executable permission (e.g., mandatory locking). When in doubt, check the underlying system behavior. The program accepts the following options. Also see . -c’‘--changes -c –changes changed owners, verbosely describingVerbosely describe the action for each file whose ownershipactually changes. -f’‘--silent’‘--quiet -f –silent –quiet error messages, omittingDo not print error messages about files whose ownership cannot bechanged. --from=old-owner –from symbolic links, changing ownerChange a file's ownership only if it has current attributes specifiedby old-owner. old-owner has the same form as new-ownerdescribed above.This option is useful primarily from a security standpoint in thatit narrows considerably the window of potential abuse.For example, to reflect a user ID numbering change for one user's fileswithout an option like this, root might run find / -owner OLDUSER -print0 | xargs -0 chown -h NEWUSER But that is dangerous because the interval between when the findtests the existing file's owner and when the chown is actually runmay be quite large.One way to narrow the gap would be to invoke chown for each fileas it is found: find / -owner OLDUSER -exec chown -h NEWUSER {} \; But that is very slow if there are many affected files.With this option, it is safer (the gap is narrower still)though still not perfect: chown -h -R --from=OLDUSER NEWUSER / --dereference –dereference symbolic links, changing owner lchownDo not act on symbolic links themselves but rather on what they point to.This is the default. -h’‘--no-dereference -h –no-dereference symbolic links, changing owner lchownAct on symbolic links themselves instead of what they point to.This mode relies on the lchown system call.On systems that do not provide the lchown system call,chown fails when a file specified on the command lineis a symbolic link.By default, no diagnostic is issued for symbolic links encounteredduring a recursive traversal, but see . --preserve-root –preserve-root root directory, disallow recursive modificationFail upon any attempt to recursively change the root directory, /.Without , this option has no effect.See . --no-preserve-root –no-preserve-root root directory, allow recursive modificationCancel the effect of any preceding option.See . --reference=ref_file –referenceChange the user and group of each file to be the same as those ofref_file. If ref_file is a symbolic link, do not use theuser and group of the symbolic link, but rather those of the file itrefers to. -v’‘--verbose -v –verboseOutput a diagnostic for every file processed.If a symbolic link is encountered during a recursive traversalon a system without the lchown system call, and is in effect, then issue a diagnostic saying neither the symbolic link norits referent is being changed. -R’‘--recursive -R –recursive recursively changing file ownershipRecursively change ownership of directories and their contents. -H -H symbolic link to directory, traverse each that is specified on the command lineIf () is specified anda command line argument is a symbolic link to a directory, traverse it.See . -L -L symbolic link to directory, traverse each that is encounteredIn a recursive traversal, traverse every symbolic link to a directorythat is encountered.See . -P -P symbolic link to directory, never traverseDo not traverse any symbolic links.This is the default if none of , ,or is specified.See . An exit status of zero indicates success, and a nonzero value indicates failure. Examples: # Change the owner of /u to "root". chown root /u # Likewise, but also change its group to "staff". chown root:staff /u # Change the owner of /u and subfiles to "root". chown -hR root /u chgrp: Change group ownership chgrp group ownership, changing changing group ownership chgrp changes the group ownership of each given file to group (which can be either a group name or a numeric group ID) or to the group of an existing reference file. Synopsis: chgrp [option]… {group | --reference=ref_file} file If group is intended to represent a numeric group ID, then you may specify it with a leading ‘+’. See . The program accepts the following options. Also see . -c’‘--changes -c –changes changed files, verbosely describingVerbosely describe the action for each file whose group actuallychanges. -f’‘--silent’‘--quiet -f –silent –quiet error messages, omittingDo not print error messages about files whose group cannot bechanged. --dereference –dereference symbolic links, changing owner lchownDo not act on symbolic links themselves but rather on what they point to.This is the default. -h’‘--no-dereference -h –no-dereference symbolic links, changing group lchownAct on symbolic links themselves instead of what they point to.This mode relies on the lchown system call.On systems that do not provide the lchown system call,chgrp fails when a file specified on the command lineis a symbolic link.By default, no diagnostic is issued for symbolic links encounteredduring a recursive traversal, but see . --preserve-root –preserve-root root directory, disallow recursive modificationFail upon any attempt to recursively change the root directory, /.Without , this option has no effect.See . --no-preserve-root –no-preserve-root root directory, allow recursive modificationCancel the effect of any preceding option.See . --reference=ref_file –referenceChange the group of each file to be the same as that ofref_file. If ref_file is a symbolic link, do not use thegroup of the symbolic link, but rather that of the file it refers to. -v’‘--verbose -v –verboseOutput a diagnostic for every file processed.If a symbolic link is encountered during a recursive traversalon a system without the lchown system call, and is in effect, then issue a diagnostic saying neither the symbolic link norits referent is being changed. -R’‘--recursive -R –recursive recursively changing group ownershipRecursively change the group ownership of directories and their contents. -H -H symbolic link to directory, traverse each that is specified on the command lineIf () is specified anda command line argument is a symbolic link to a directory, traverse it.See . -L -L symbolic link to directory, traverse each that is encounteredIn a recursive traversal, traverse every symbolic link to a directorythat is encountered.See . -P -P symbolic link to directory, never traverseDo not traverse any symbolic links.This is the default if none of , ,or is specified.See . An exit status of zero indicates success, and a nonzero value indicates failure. Examples: # Change the group of /u to "staff". chgrp staff /u # Change the group of /u and subfiles to "staff". chgrp -hR staff /u chmod: Change access permissions chmod changing access permissions access permissions, changing permissions, changing access chmod changes the access permissions of the named files. Synopsis: chmod [option]… {mode | --reference=ref_file} file symbolic links, permissions of chmod never changes the permissions of symbolic links, since the chmod system call cannot change their permissions. This is not a problem since the permissions of symbolic links are never used. However, for each symbolic link listed on the command line, chmod changes the permissions of the pointed-to file. In contrast, chmod ignores symbolic links encountered during recursive directory traversals. A successful use of chmod clears the set-group-ID bit of a regular file if the file's group ID does not match the user's effective group ID or one of the user's supplementary group IDs, unless the user has appropriate privileges. Additional restrictions may cause the set-user-ID and set-group-ID bits of mode or ref_file to be ignored. This behavior depends on the policy and functionality of the underlying chmod system call. When in doubt, check the underlying system behavior. If used, mode specifies the new file mode bits. For details, see the section on . If you really want mode to have a leading ‘-’, you should use first, e.g., ‘chmod -- -w file’. Typically, though, ‘chmod a-w file’ is preferable, and chmod -w file (without the ) complains if it behaves differently from what ‘chmod a-w file’ would do. The program accepts the following options. Also see . -c’‘--changes -c –changesVerbosely describe the action for each file whose permissionsactually changes. -f’‘--silent’‘--quiet -f –silent –quiet error messages, omittingDo not print error messages about files whose permissions cannot bechanged. --preserve-root –preserve-root root directory, disallow recursive modificationFail upon any attempt to recursively change the root directory, /.Without , this option has no effect.See . --no-preserve-root –no-preserve-root root directory, allow recursive modificationCancel the effect of any preceding option.See . -v’‘--verbose -v –verboseVerbosely describe the action or non-action taken for every file. --reference=ref_file –referenceChange the mode of each file to be the same as that of ref_file.See .If ref_file is a symbolic link, do not use the modeof the symbolic link, but rather that of the file it refers to. -R’‘--recursive -R –recursive recursively changing access permissionsRecursively change permissions of directories and their contents. An exit status of zero indicates success, and a nonzero value indicates failure. touch: Change file timestamps touch changing file timestamps file timestamps, changing timestamps, changing file touch changes the access and/or modification times of the specified files. Synopsis: touch [option]… file empty files, creating Any file that does not exist is created empty. A file of ‘-’ causes touch to change the times of the file associated with standard output. permissions, for changing file timestamps If changing both the access and modification times to the current time, 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. Although touch provides options for changing two of the times—the times of last access and modification—of a file, there is actually a third one as well: the inode change time. This is often referred to as a file's ctime. The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change. Changing the permissions doesn't access the file, so the atime doesn't change, nor does it modify the file, so the mtime doesn't change. Yet, something about the file itself has changed, and this must be noted somewhere. This is the job of the ctime field. This is necessary, so that, for example, a backup program can make a fresh copy of the file, including the new permissions value. Another operation that modifies a file's ctime without affecting the others is renaming. In any case, it is not possible, in normal operations, for a user to change the ctime field to a user-specified value. TZ Time stamps assume the time zone rules specified by the TZ environment variable, or by the system default rules if TZ is not set. See See section ``Specifying the Time Zone with @env{TZ}'' in The GNU C Library. You can avoid ambiguities during daylight saving transitions by using utc time stamps. The program accepts the following options. Also see . -a’‘--time=atime’‘--time=access’‘--time=use -a –time atime, changing access time, changing use time, changingChange the access time only. -c’‘--no-create -c –no-createDo not create files that do not exist. -d’‘--date=time -d –date timeUse time instead of the current time. It can contain month names,time zones, ‘am’ and ‘pm’, ‘yesterday’, etc. Forexample, specifies the instant of time that is 489,392,193 nanoseconds afterFebruary 27, 2004 at 2:19:13 PM in a time zone that is 5 hours and 30minutes east of UTC. See .File systems that do not support high-resolution time stampssilently ignore any excess precision here. -f -f BSD touch compatibilityIgnored; for compatibility with BSD versions of touch. -m’‘--time=mtime’‘--time=modify -m –time mtime, changing modify time, changingChange the modification time only. -r file’‘--reference=file -r –referenceUse the times of the reference file instead of the current time.If this option is combined with the () option, the reference file's time isthe origin for any relative times given, but is otherwise ignored.For example, ‘-r foo -d '-5 seconds'’ specifies a time stampequal to five seconds before the corresponding time stamp for foo. -t [[CC]YY]MMDDhhmm[.ss]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 CCis 20 for years in the range 0 … 68, and 19 for years in69 … 99. If no digits of the year are specified,the argument is interpreted as a date in the current year. _POSIX2_VERSION On older systems, touch supports an obsolete syntax, as follows. If no timestamp is given with any of the , , or options, and if there are two or more files and the first file is of the form ‘MMDDhhmm[YY]’ and this would be a valid argument to the option (if the YY, if any, were moved to the front), and if the represented year is in the range 1969–1999, that argument is interpreted as the time for the other files instead of as a file name. This obsolete behavior can be enabled or disabled with the _POSIX2_VERSION environment variable (see ), but portable scripts should avoid commands whose behavior depends on this variable. For example, use ‘touch ./12312359 main.c’ or ‘touch -t 12312359 main.c’ rather than the ambiguous ‘touch 12312359 main.c’. An exit status of zero indicates success, and a nonzero value indicates failure. Disk usage disk usage No disk can hold an infinite amount of data. These commands report how much disk storage is in use or available, report other file and file status information, and write buffers to disk. df: Report file system disk space usage df file system disk usage disk usage by file system df reports the amount of disk space used and available on file systems. Synopsis: df [option]… [file]… With no arguments, df reports the space used and available on all currently mounted file systems (of all types). Otherwise, df reports on the file system containing each argument file. Normally the disk space is printed in units of 1024 bytes, but this can be overridden (see ). Non-integer quantities are rounded up to the next higher unit. disk device file device file, disk If an argument file is a disk device file containing a mounted file system, 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). gnu 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 structures. The program accepts the following options. Also see . -a’‘--all -a –all automounter file systems ignore file systemsInclude in the listing dummy file systems, whichare omitted by default. Such file systems are typically special-purposepseudo-file-systems, such as automounter entries. -B size’‘--block-size=size -B –block-size file system sizesScale sizes by size before printing them (see ).For example, prints sizes in units of 1,073,741,824 bytes. -h’‘--human-readable -h –human-readable human-readable outputAppend a size letter to each size, such as ‘M’ for mebibytes.Powers of 1024 are used, not 1000; ‘M’ stands for 1,048,576 bytes.Use the option if you prefer powers of 1000. -H -HEquivalent to . -i’‘--inodes -i –inodes inode usageList inode usage information instead of block usage. An inode (shortfor index node) contains information about a file such as its owner,permissions, timestamps, and location on the disk. -k -k kibibytes for file system sizesPrint sizes in 1024-byte blocks, overriding the default block size(see ).This option is equivalent to . -l’‘--local -l –local file system types, limiting output to certainLimit the listing to local file systems. By default, remote file systemsare also listed. --no-sync –no-sync file system space, retrieving old data more quicklyDo not invoke the sync system call before getting any usage data.This may make df run significantly faster on systems with manydisks, but on some systems (notably SunOS) the results may be slightlyout of date. This is the default. -P’‘--portability -P –portability one-line output format POSIX output format portable output format output format, portableUse the POSIX output format. This is like the default format exceptfor the following: The information about each file system is always printed on exactlyone line; a mount device is never put on a line by itself. This meansthat if the mount device name is more than 20 characters long (e.g., forsome network mounts), the columns are misaligned. The labels in the header output line are changed to conform to POSIX. The default block size and output format are unaffected by theDF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environmentvariables. However, the default block size is still affected byPOSIXLY_CORRECT: it is 512 if POSIXLY_CORRECT is set, 1024otherwise. See . --si –si SI outputAppend an SI-style abbreviation to each size, such as ‘M’ formegabytes. Powers of 1000 are used, not 1024; ‘M’ stands for1,000,000 bytes. This option is equivalent to. Use the or option ifyou prefer powers of 1024. --sync –sync file system space, retrieving current data more slowlyInvoke the sync system call before getting any usage data. Onsome systems (notably SunOS), doing this yields more up to date results,but in general this option makes df much slower, especially whenthere are many or very busy file systems. -t fstype’‘--type=fstype -t –type file system types, limiting output to certainLimit the listing to file systems of type fstype. Multiplefile system types can be specified by giving multiple options.By default, nothing is omitted. -T’‘--print-type -T –print-type file system types, printingPrint each file system's type. The types printed here are the same onesyou can include or exclude with and . The particulartypes printed are whatever is supported by the system. Here are some ofthe common names (this list is certainly not exhaustive): nfs NFS file system typeAn NFS file system, i.e., one mounted over a network from anothermachine. This is the one type name which seems to be used uniformly byall systems. 4.2, ufs, efs… Linux file system types local file system types 4.2 file system type ufs file system type efs file system typeA file system on a locally-mounted hard disk. (The system might evensupport more than one type here; Linux does.) hsfs, cdfs CD-ROM file system type High Sierra file system hsfs file system type cdfs file system typeA file system on a CD-ROM drive. HP-UX uses ‘cdfs’, most othersystems use ‘hsfs’ (‘hs’ for “High Sierra”). pcfs PC file system DOS file system MS-DOS file system diskette file system pcfsAn MS-DOS file system, usually on a diskette. -x fstype’‘--exclude-type=fstype -x –exclude-typeLimit the listing to file systems not of type fstype.Multiple file system types can be eliminated by giving multiple options. By default, no file system types are omitted. -vIgnored; for compatibility with System V versions of df. An exit status of zero indicates success, and a nonzero value indicates failure. Failure includes the case where no output is generated, so you can inspect the exit status of a command like ‘df -t ext3 -t reiserfs dir’ to test whether dir is on a file system of type ‘ext3’ or ‘reiserfs’. du: Estimate file space usage du file space usage disk usage for files du reports the amount of disk space used by the specified files and for each subdirectory (of directory arguments). Synopsis: du [option]… [file]… With no arguments, du reports the disk space for the current directory. Normally the disk space is printed in units of 1024 bytes, but this can be overridden (see ). Non-integer quantities are rounded up to the next higher unit. The program accepts the following options. Also see . -a’‘--all -a –allShow counts for all files, not just directories. --apparent-size –apparent-sizePrint apparent sizes, rather than disk usage. The apparent size of afile is the number of bytes reported by wc -c on regular files,or more generally, ls -l --block-size=1 or stat --format=%s.For example, a file containing the word ‘zoo’ with no newline would,of course, have an apparent size of 3. Such a small file may requireanywhere from 0 to 16 KiB or more of disk space, depending onthe type and configuration of the file system on which the file resides.However, a sparse file created with this command: dd bs=1 seek=2GiB if=/dev/null of=big has an apparent size of 2 GiB, yet on most modernsystems, it actually uses almost no disk space. -b’‘--bytes -b –bytesEquivalent to --apparent-size --block-size=1. -B size’‘--block-size=size -B –block-size file sizesScale sizes by size before printing them (see ).For example, prints sizes in units of 1,073,741,824 bytes. -c’‘--total -c –total grand total of disk spacePrint a grand total of all arguments after all arguments havebeen processed. This can be used to find out the total disk usage ofa given set of files or directories. -D’‘--dereference-args -D –dereference-argsDereference symbolic links that are command line arguments.Does not affect other symbolic links. This is helpful for findingout the disk usage of directories, such as /usr/tmp, whichare often symbolic links. --files0-from=FILE –files0-from=FILE including files from duRather than processing files named on the command line, process thosenamed in file FILE; each name is terminated by a null byte.This is useful with the () option whenthe list of file names is so long that it may exceed a command linelength limitation.In such cases, running du via xargs is undesirablebecause it splits the list into pieces and makes du print atotal for each sublist rather than for the entire list.One way to produce a list of null-byte-terminated file names is with gnufind, using its predicate.Do not specify any FILE on the command line when using this option. -h’‘--human-readable -h –human-readable human-readable outputAppend a size letter to each size, such as ‘M’ for mebibytes.Powers of 1024 are used, not 1000; ‘M’ stands for 1,048,576 bytes.Use the option if you prefer powers of 1000. -H -HCurrently, is the same as ,except that evokes a warning.This option will be changed to be equivalent to (). -k -k kibibytes for file sizesPrint sizes in 1024-byte blocks, overriding the default block size(see ).This option is equivalent to . -l’‘--count-links -l –count-links hard links, counting in duCount the size of all files, even if they have appeared already (as ahard link). -L’‘--dereference -L –dereference symbolic links, dereferencing in duDereference symbolic links (show the disk space used by the fileor directory that the link points to instead of the space used bythe link). -m -m mebibytes for file sizesPrint sizes in 1,048,576-byte blocks, overriding the default block size(see ).This option is equivalent to . -P’‘--no-dereference -P –no-dereference symbolic links, dereferencing in duFor each symbolic links encountered by du,consider the disk space used by the symbolic link. --max-depth=DEPTH –max-depth=DEPTH limiting output of duShow the total for each directory (and file if –all) that is atmost MAX_DEPTH levels down from the root of the hierarchy. The rootis at level 0, so du --max-depth=0 is equivalent to du -s. -0 -0 --null –null output null-byte-terminated linesOutput a null byte at the end of each line, rather than a newline.This option enables other programs to parse the output of dueven when that output would contain file names with embedded newlines. --si –si SI outputAppend an SI-style abbreviation to each size, such as ‘MB’ formegabytes. Powers of 1000 are used, not 1024; ‘MB’ stands for1,000,000 bytes. Use the or option ifyou prefer powers of 1024. -s’‘--summarize -s –summarizeDisplay only a total for each argument. -S’‘--separate-dirs -S –separate-dirsReport the size of each directory separately, not including the sizesof subdirectories. --time –time last modified dates, displaying in duShow time of the most recent modification of any file in the directory,or any of its subdirectories. --time=ctime’‘--time=status’‘--time=use –time ctime, show the most recent status time, show the most recent use time, show the most recentShow the most recent status change time (the ‘ctime’ in the inode) ofany file in the directory, instead of the modification time. --time=atime’‘--time=access –time atime, show the most recent access time, show the most recentShow the most recent access time (the ‘atime’ in the inode) ofany file in the directory, instead of the modification time. --time-style=style –time-style time styleList timestamps in style style. This option has an effect only ifthe option is also specified. The style shouldbe one of the following: +format LC_TIMEList timestamps using format, where format is interpretedlike the format argument of date (see ).For example, causesdu to list timestamps like ‘2002-03-30 23:45:56’. Aswith date, format's interpretation is affected by theLC_TIME locale category. full-isoList timestamps in full using ISO 8601 date, time, and time zoneformat with nanosecond precision, e.g., ‘2002-03-3023:45:56.477817180 -0700’. This style is equivalent to‘+%Y-%m-%d %H:%M:%S.%N %z’. long-isoList ISO 8601 date and time in minutes, e.g.,‘2002-03-30 23:45’. These timestamps are shorter than‘full-iso’ timestamps, and are usually good enough for everydaywork. This style is equivalent to ‘+%Y-%m-%d %H:%M’. isoList ISO 8601 dates for timestamps, e.g., ‘2002-03-30’.This style is equivalent to ‘+%Y-%m-%d’. TIME_STYLEYou can specify the default value of the optionwith the environment variable TIME_STYLE; if TIME_STYLE is not setthe default style is ‘long-iso’. For compatibility with ls,if TIME_STYLE begins with ‘+’ and contains a newline,the newline and any later characters are ignored; if TIME_STYLEbegins with ‘posix-’ the ‘posix-’ is ignored; and ifTIME_STYLE is ‘locale’ it is ignored. -x’‘--one-file-system -x –one-file-system one file system, restricting du toSkip directories that are on different file systems from the one thatthe argument being processed is on. --exclude=PATTERN –exclude=PATTERN excluding files from duWhen recursing, skip subdirectories or files matching PATTERN.For example, du --exclude='*.o' excludes files whose namesend in ‘.o’. -X FILE’‘--exclude-from=FILE -X FILE –exclude-from=FILE excluding files from duLike , except take the patterns to exclude from FILE,one per line. If FILE is ‘-’, take the patterns from standardinput. NFS mounts from BSD to HP-UX On BSD systems, du reports sizes that are half the correct values for files that are NFS-mounted from HP-UX systems. On HP-UX systems, it reports sizes that are twice the correct values for files that are NFS-mounted from BSD systems. This is due to a flaw in HP-UX; it also affects the HP-UX du program. An exit status of zero indicates success, and a nonzero value indicates failure. stat: Report file or file system status stat file status file system status stat displays information about the specified file(s). Synopsis: stat [option]… [file]… With no option, stat reports all information about the given files. But it also can be used to report the information of the file systems the given files are located on. If the files are links, stat can also give information about the files the links point to. -L’‘--dereference -L –dereference symbolic links, dereferencing in statChange how stat treats symbolic links.With this option, stat acts on the file referencedby each symbolic link argument.Without it, stat acts on any symbolic link argument directly. -f’‘--file-system -f –file-system file systemsReport information about the file systems where the given files are locatedinstead of information about the files themselves. -c’‘--format=format -c –format=format output formatUse format rather than the default format.format is automatically newline-terminated, sorunning a command like the following with two or more fileoperands produces a line of output for each operand: $ stat --format=%d:%i / /usr 2050:2 2057:2 --printf=format –printf=format output formatUse format rather than the default format.Like , but interpret backslash escapes,and do not output a mandatory trailing newline.If you want a newline, include ‘\n’ in the format.Here's how you would use to print the deviceand inode numbers of / and /usr: $ stat --printf='%d:%i\n' / /usr 2050:2 2057:2 -t’‘--terse -t –terse terse outputPrint the information in terse form, suitable for parsing by other programs.The valid format sequences for files are: %a - Access rights in octal %A - Access rights in human readable form %b - Number of blocks allocated (see ‘%B’) %B - The size in bytes of each block reported by ‘%b %d - Device number in decimal %D - Device number in hex %f - Raw mode in hex %F - File type %g - Group ID of owner %G - Group name of owner %h - Number of hard links %i - Inode number %n - File name %N - Quoted file name with dereference if symbolic link %o - I/O block size %s - Total size, in bytes %t - Major device type in hex %T - Minor device type in hex %u - User ID of owner %U - User name of owner %x - Time of last access %X - Time of last access as seconds since Epoch %y - Time of last modification %Y - Time of last modification as seconds since Epoch %z - Time of last change %Z - Time of last change as seconds since Epoch The valid format sequences for file systems are: %a - Free blocks available to non-super-user %b - Total data blocks in file system %c - Total file nodes in file system %d - Free file nodes in file system %f - Free blocks in file system %i - File System ID in hex %l - Maximum length of file names %n - File name %s - Block size (for faster transfers) %S - Fundamental block size (for block counts) %t - Type in hex %T - Type in human readable form TZTime stamps are listed according to the time zone rules specified bythe TZ environment variable, or by the system default rules ifTZ is not set. See See section ``Specifying the Time Zonewith @env{TZ}'' in The GNU C Library. An exit status of zero indicates success, and a nonzero value indicates failure. sync: Synchronize data on disk with memory sync synchronize disk and memory superblock, writing inodes, written buffered sync writes any data buffered in memory out to disk. This can include (but is not limited to) modified superblocks, modified inodes, and delayed reads and writes. This must be implemented by the kernel; The sync program does nothing but exercise the sync system call. crashes and corruption The kernel keeps data in memory to avoid doing (relatively slow) disk reads and writes. This improves performance, but if the computer crashes, data may be lost or the file system corrupted as a result. The sync command ensures everything in memory is written to disk. Any arguments are ignored, except for a lone or (see ). An exit status of zero indicates success, and a nonzero value indicates failure. Printing text printing text, commands for commands for printing text This section describes commands that display text strings. echo: Print a line of text echo displaying text printing text text, displaying arbitrary text, displaying echo writes each given string to standard output, with a space between each and a newline after the last one. Synopsis: echo [option]… [string]… The program accepts the following options. Also see . Options must precede operands, and the normally-special argument ‘--’ has no special meaning and is treated like any other string. -n -nDo not output the trailing newline. -e -e backslash escapesEnable interpretation of the following backslash-escaped characters ineach string: \aalert (bell) \bbackspace \csuppress trailing newline \fform feed \nnew line \rcarriage return \thorizontal tab \vvertical tab \\backslash \0nnnthe eight-bit value that is the octal number nnn(zero to three octal digits) \nnnthe eight-bit value that is the octal number nnn(one to three octal digits) \xhhthe eight-bit value that is the hexadecimal number hh(one or two hexadecimal digits) -E -E backslash escapesDisable interpretation of backslash escapes in each string.This is the default. If and are bothspecified, the last one given takes effect. POSIXLY_CORRECT If the POSIXLY_CORRECT environment variable is set, then when echo's first argument is not it outputs option-like arguments instead of treating them as options. For example, echo -ne hello outputs ‘-ne hello’ instead of plain ‘hello’. POSIX does not require support for any options, and says that the behavior of echo is implementation-defined if any string contains a backslash or if the first argument is . Portable programs can use the printf command if they need to omit trailing newlines or output control characters or backslashes. See . An exit status of zero indicates success, and a nonzero value indicates failure. printf: Format and print data printf printf does formatted printing of text. Synopsis: printf format [argument]… printf prints the format string, interpreting ‘%’ directives and ‘\’ escapes to format numeric and string arguments in a way that is mostly similar to the C ‘printf’ function. The differences are as follows: The format argument is reused as necessary to convert all thegiven arguments. For example, the command ‘printf %s a b’outputs ‘ab’. Missing arguments are treated as null strings or as zeros,depending on whether the context expects a string or a number. Forexample, the command ‘printf %sx%d’ prints ‘x0’. \cAn additional escape, ‘\c’, causes printf to produce nofurther output. For example, the command ‘printf 'A%sC\cD%sF' BE’ prints ‘ABC’. The hexadecimal escape sequence ‘\xhh’ has at most twodigits, as opposed to C where it can have an unlimited number ofdigits. For example, the command ‘printf '\x07e'’ prints twobytes, whereas the C statement ‘printf ("\x07e")’ prints justone. %bprintf has an additional directive, ‘%b’, which prints itsargument string with ‘\’ escapes interpreted in the same way as inthe format string, except that octal escapes are of the form‘\0ooo’ where ooo is 0 to 3 octal digits.If a precision is also given, it limits the number of bytes printedfrom the converted string. Numeric arguments must be single C constants, possibly with leading‘+’ or ‘-’. For example, ‘printf %.4d -3’ outputs‘-0003’. POSIXLY_CORRECTIf the leading character of a numeric argument is ‘"’ or ‘'’then its value is the numeric value of the immediately followingcharacter. Any remaining characters are silently ignored if thePOSIXLY_CORRECT environment variable is set; otherwise, awarning is printed. For example, ‘printf "%d" "'a"’ outputs‘97’ on hosts that use the ASCII character set, since‘a’ has the numeric value 97 in ASCII. LC_NUMERIC A floating-point argument must use a period before any fractional digits, but is printed according to the LC_NUMERIC category of the current locale. For example, in a locale whose radix character is a comma, the command ‘printf %g 3.14’ outputs ‘3,14’ whereas the command ‘printf %g 3,14’ is an error. \ooo \xhh printf interprets ‘\ooo’ in format as an octal number (if ooo is 1 to 3 octal digits) specifying a character to print, and ‘\xhh’ as a hexadecimal number (if hh is 1 to 2 hex digits) specifying a character to print. \uhhhh \Uhhhhhhhh Unicode ISO/IEC 10646 LC_CTYPE printf interprets two character syntaxes introduced in ISO C 99: ‘\u’ for 16-bit Unicode (ISO/IEC 10646) characters, specified as four hexadecimal digits hhhh, and ‘\U’ for 32-bit Unicode characters, specified as eight hexadecimal digits hhhhhhhh. printf outputs the Unicode characters according to the LC_CTYPE locale. The processing of ‘\u’ and ‘\U’ requires a full-featured iconv facility. It is activated on systems with glibc 2.2 (or newer), or when libiconv is installed prior to this package. Otherwise ‘\u’ and ‘\U’ will print as-is. The only options are a lone or . See . Options must precede operands. The Unicode character syntaxes are useful for writing strings in a locale independent way. For example, a string containing the Euro currency symbol $ /usr/local/bin/printf '\u20AC 14.95' will be output correctly in all locales supporting the Euro symbol (ISO-8859-15, UTF-8, and others). Similarly, a Chinese string $ /usr/local/bin/printf '\u4e2d\u6587' will be output correctly in all Chinese locales (GB2312, BIG5, UTF-8, etc). Note that in these examples, the full name of printf has been given, to distinguish it from the GNU bash built-in function printf. For larger strings, you don't need to look up the hexadecimal code 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 this text in a locale-independent way: $ LC_CTYPE=zh_CN.big5 /usr/local/bin/printf \ '\u4e2d\u6587\n' > sample.txt $ recode BIG5..JAVA < sample.txt \ | sed -e "s|^|/usr/local/bin/printf '|" -e "s|$|\\\\n'|" \ > sample.sh An exit status of zero indicates success, and a nonzero value indicates failure. yes: Print a string until interrupted yes repeated output of a string yes prints the command line arguments, separated by spaces and followed by a newline, forever until it is killed. If no arguments are given, it prints ‘y’ followed by a newline forever until killed. Upon a write error, yes exits with status ‘1’. The only options are a lone or . To output an argument that begins with ‘-’, precede it with , e.g., ‘yes -- --help’. See . Conditions conditions commands for exit status exit status commands This section describes commands that are primarily useful for their exit status, rather than their output. Thus, they are often used as the condition of shell if statements, or as the last command in a pipeline. false: Do nothing, unsuccessfully false do nothing, unsuccessfully failure exit status exit status of false false does nothing except return an exit status of 1, meaning failure. It can be used as a place holder in shell scripts where an unsuccessful command is needed. In most modern shells, false is a built-in command, so when you use ‘false’ in a script, you're probably using the built-in command, not the one documented here. false honors the and options. This version of false is implemented as a C program, and is thus more secure and faster than a shell script implementation, and may safely be used as a dummy shell for the purpose of disabling accounts. Note that false (unlike all other programs documented herein) exits unsuccessfully, even when invoked with or . Portable programs should not assume that the exit status of false is 1, as it is greater than 1 on some non-GNU hosts. true: Do nothing, successfully true do nothing, successfully no-op successful exit exit status of true true does nothing except return an exit status of 0, meaning success. It can be used as a place holder in shell scripts where a successful command is needed, although the shell built-in command : (colon) may do the same thing faster. In most modern shells, true is a built-in command, so when you use ‘true’ in a script, you're probably using the built-in command, not the one documented here. true honors the and options. Note, however, that it is possible to cause true to exit with nonzero status: with the or option, and with standard output already closed or redirected to a file that evokes an I/O error. For example, using a Bourne-compatible shell: $ ./true --version >&- ./true: write error: Bad file number $ ./true --version > /dev/full ./true: write error: No space left on device This version of true is implemented as a C program, and is thus more secure and faster than a shell script implementation, and may safely be used as a dummy shell for the purpose of disabling accounts. test: Check file types and compare values test check file types compare values expression evaluation test returns a status of 0 (true) or 1 (false) depending on the evaluation of the conditional expression expr. Each part of the expression must be a separate argument. test has file status checks, string operators, and numeric comparison operators. test has an alternate form that uses opening and closing square brackets instead a leading ‘test’. For example, instead of ‘test -d /’, you can write ‘[ -d / ]’. The square brackets must be separate arguments; for example, ‘[-d /]’ does not have the desired effect. Since ‘test expr’ and ‘[ expr ]’ have the same meaning, only the former form is discussed below. Synopses: test expression test [ expression ] [ ] [ option conflicts with shell built-ins built-in shell commands, conflicts with Because most shells have a built-in test command, using an unadorned test in a script or interactively may get you different functionality than that described here. If expression is omitted, test returns false. If expression is a single argument, test returns false if the argument is null and true otherwise. The argument can be any string, including strings like ‘-d’, ‘-1’, ‘--’, ‘--help’, and ‘--version’ that most other programs would treat as options. To get help and version information, invoke the commands ‘[ --help’ and ‘[ --version’, without the usual closing brackets. See . exit status of test Exit status: 0 if the expression is true, 1 if the expression is false, 2 if an error occurred. File type tests file type tests These options test for particular types of files. (Everything's a file, but not all files are the same!) -b file -b block special checkTrue if file exists and is a block special device. -c file -c character special checkTrue if file exists and is a character special device. -d file -d directory checkTrue if file exists and is a directory. -f file -f regular file checkTrue if file exists and is a regular file. -h file’‘-L file -L -h symbolic link checkTrue if file exists and is a symbolic link.Unlike all other file-related tests, this test does not dereferencefile if it is a symbolic link. -p file -p named pipe checkTrue if file exists and is a named pipe. -S file -S socket checkTrue if file exists and is a socket. -t fd -t terminal checkTrue if fd is a file descriptor that is associated with aterminal. Access permission tests access permission tests permission tests These options test for particular access permissions. -g file -g set-group-ID checkTrue if file exists and has its set-group-ID bit set. -k file -k sticky bit checkTrue if file exists and has its sticky bit set. -r file -r readable file checkTrue if file exists and read permission is granted. -u file -u set-user-ID checkTrue if file exists and has its set-user-ID bit set. -w file -w writable file checkTrue if file exists and write permission is granted. -x file -x executable file checkTrue if file exists and execute permission is granted(or search permission, if it is a directory). -O file -O owned by effective user ID checkTrue if file exists and is owned by the current effective user ID. -G file -G owned by effective group ID checkTrue if file exists and is owned by the current effective group ID. File characteristic tests file characteristic tests These options test other file characteristics. -e file -e existence-of-file checkTrue if file exists. -s file -s nonempty file checkTrue if file exists and has a size greater than zero. file1 -nt file2 -nt newer-than file checkTrue if file1 is newer (according to modification date) thanfile2, or if file1 exists and file2 does not. file1 -ot file2 -ot older-than file checkTrue if file1 is older (according to modification date) thanfile2, or if file2 exists and file1 does not. file1 -ef file2 -ef same file check hard link checkTrue if file1 and file2 have the same device and inodenumbers, i.e., if they are hard links to each other. String tests string tests These options test string characteristics. You may need to quote string arguments for the shell. For example: test -n "$V" The quotes here prevent the wrong arguments from being passed to test if ‘$V’ is empty or contains special characters. -z string -z zero-length string checkTrue if the length of string is zero. -n string’‘string -n nonzero-length string checkTrue if the length of string is nonzero. string1 = string2 = equal string checkTrue if the strings are equal. string1 != string2 != not-equal string checkTrue if the strings are not equal. Numeric tests numeric tests arithmetic tests Numeric relationals. The arguments must be entirely numeric (possibly negative), or the special expression -l string, which evaluates to the length of string. arg1 -eq arg2’‘arg1 -ne arg2’‘arg1 -lt arg2’‘arg1 -le arg2’‘arg1 -gt arg2’‘arg1 -ge arg2 -eq -ne -lt -le -gt -geThese arithmetic binary operators return true if arg1 is equal,not-equal, less-than, less-than-or-equal, greater-than, orgreater-than-or-equal than arg2, respectively. For example: test -1 -gt -2 && echo yes => yes test -l abc -gt 1 && echo yes => yes test 0x100 -eq 1 error--> test: integer expression expected before -eq Connectives for test logical connectives connectives, logical The usual logical connectives. ! expr !True if expr is false. expr1 -a expr2 -a logical and operator and operatorTrue if both expr1 and expr2 are true. expr1 -o expr2 -o logical or operator or operatorTrue if either expr1 or expr2 is true. expr: Evaluate expressions expr expression evaluation evaluation of expressions expr evaluates an expression and writes the result on standard output. Each token of the expression must be a separate argument. Operands are either integers or strings. Integers consist of one or more decimal digits, with an optional leading ‘-’. expr converts anything appearing in an operand position to an integer or a string depending on the operation being applied to it. Strings are not quoted for expr itself, though you may need to quote them to protect characters with special meaning to the shell, e.g., spaces. However, regardless of whether it is quoted, a string operand should not be a parenthesis or any of expr's operators like +, so you cannot safely pass an arbitrary string $str to expr merely by quoting it to the shell. One way to work around this is to use the gnu extension +, (e.g., + "$str" = foo); a more portable way is to use " $str" and to adjust the rest of the expression to take the leading space into account (e.g., " $str" = " foo"). You should not pass a negative integer or a string with leading ‘-’ as expr's first argument, as it might be misinterpreted as an option; this can be avoided by parenthesization. Also, portable scripts should not use a string operand that happens to take the form of an integer; this can be worked around by inserting leading spaces as mentioned above. parentheses for grouping Operators may be given as infix symbols or prefix keywords. Parentheses may be used for grouping in the usual manner. You must quote parentheses and many operators to avoid the shell evaluating them, however. The only options are and . See . Options must precede operands. exit status of expr Exit status: 0 if the expression is neither null nor 0, 1 if the expression is null or 0, 2 if the expression is invalid, 3 if an internal error occurred (e.g., arithmetic overflow). String expressions string expressions expressions, string expr supports pattern matching and other string operators. These have lower precedence than both the numeric and relational operators (in the next sections). string : regex pattern matching regular expression matching matching patternsPerform pattern matching. The arguments are converted to strings and thesecond is considered to be a (basic, a la GNU grep) regularexpression, with a ^ implicitly prepended. The first argument isthen matched against this regular expression.If the match succeeds and regex uses ‘\(’ and ‘\)’, the: expression returns the part of string that matched thesubexpression; otherwise, it returns the number of characters matched.If the match fails, the : operator returns the null string if‘\(’ and ‘\)’ are used in regex, otherwise 0. \( regexp operatorOnly the first ‘\( … \)’ pair is relevant to the returnvalue; additional pairs are meaningful only for grouping the regularexpression operators. \+ regexp operator \? regexp operator \| regexp operatorIn the regular expression, \+, \?, and \| areoperators which respectively match one or more, zero or one, or separatealternatives. SunOS and other expr's treat these as regularcharacters. (POSIX allows either behavior.)See See section ``Regular Expression Library'' in Regex, for details ofregular expression syntax. Some examples are in . match string regex matchAn alternative way to do pattern matching. This is the same as‘string : regex. substr string position length substrReturns the substring of string beginning at positionwith length at most length. If either position orlength is negative, zero, or non-numeric, returns the null string. index string charset indexReturns the first position in string where the first character incharset was found. If no character in charset is found instring, return 0. length string lengthReturns the length of string. + token +Interpret token as a string, even if it is a keyword like matchor an operator like /.This makes it possible to test expr length + "$x" orexpr + "$x" : '.*/\(.\)' and have it do the right thing even ifthe value of $x happens to be (for example) / or index.This operator is a GNU extension. Portable shell scripts should use" $token" : ' \(.*\)' instead of + "$token". To make expr interpret keywords as strings, you must use the quote operator. Numeric expressions numeric expressions expressions, numeric expr supports the usual numeric operators, in order of increasing precedence. The string operators (previous section) have lower precedence, the connectives (next section) have higher. + - + - addition subtractionAddition and subtraction. Both arguments are converted to integers;an error occurs if this cannot be done. * / % * / % multiplication division remainderMultiplication, division, remainder. Both arguments are converted tointegers; an error occurs if this cannot be done. Relations for expr connectives, logical logical connectives relations, numeric or string expr supports the usual logical connectives and relations. These are higher precedence than either the string or numeric operators (previous sections). Here is the list, lowest-precedence operator first. | | logical or operator or operatorReturns its first argument if that is neither null nor zero, otherwiseits second argument if it is neither null nor zero, otherwise 0. Itdoes not evaluate its second argument if its first argument is neithernull nor zero. & & logical and operator and operatorReturn its first argument if neither argument is null or zero, otherwise0. It does not evaluate its second argument if its first argument isnull or zero. < <= = == != >= > < <= = == > >= comparison operators LC_COLLATECompare the arguments and return 1 if the relation is true, 0 otherwise.== is a synonym for =. expr first tries to convertboth arguments to integers and do a numeric comparison; if eitherconversion fails, it does a lexicographic comparison using the charactercollating sequence specified by the LC_COLLATE locale. Examples of using expr examples of expr Here are a few examples, including quoting for shell metacharacters. To add 1 to the shell variable foo, in Bourne-compatible shells: foo=`expr $foo + 1` To print the non-directory part of the file name stored in $fname, which need not contain a /: expr $fname : '.*/\(.*\)' '|' $fname An example showing that \+ is an operator: expr aaa : 'a\+' => 3 expr abc : 'a\(.\)c' => b expr index abcdef cz => 3 expr index index a error--> expr: syntax error expr index quote index a => 0 Redirection redirection commands for redirection Unix shells commonly provide several forms of redirection—ways to change the input source or output destination of a command. But one useful redirection is performed by a separate command, not by the shell; it's described here. tee: Redirect output to multiple files tee pipe fitting destinations, multiple output read from stdin and write to stdout and files The tee command copies standard input to standard output and also to any files given as arguments. This is useful when you want not only to send some data down a pipe, but also to save a copy. Synopsis: tee [option]… [file]… If a file being written to does not already exist, it is created. If a file being written to already exists, the data it previously contained is overwritten unless the option is used. A file of ‘-’ causes tee to send another copy of input to standard output, but this is typically not that useful as the copies are interleaved. The program accepts the following options. Also see . -a’‘--append -a –appendAppend standard input to the given files rather than overwritingthem. -i’‘--ignore-interrupts -i –ignore-interruptsIgnore interrupt signals. An exit status of zero indicates success, and a nonzero value indicates failure. File name manipulation file name manipulation manipulation of file names commands for file name manipulation This section describes commands that manipulate file names. basename: Strip directory and suffix from a file name basename strip directory and suffix from file names directory, stripping from file names suffix, stripping from file names file names, stripping directory and suffix leading directory components, stripping basename removes any leading directory components from name. Synopsis: basename name [suffix] If suffix is specified and is identical to the end of name, it is removed from name as well. Note that since trailing slashes are removed prior to suffix matching, suffix will do nothing if it contains slashes. basename prints the result on standard output. Together, basename and dirname are designed such that if ‘ls "$name"’ succeeds, then the command sequence ‘cd "$(dirname "$name")"; ls "$(basename "$name")"’ will, too. This works for everything except file names containing a trailing newline. POSIX allows the implementation to define the results if name is empty or ‘//’. In the former case, GNU basename returns the empty string. In the latter case, the result is ‘//’ on platforms where // is distinct from /, and ‘/’ on platforms where there is no difference. The only options are and . See . Options must precede operands. An exit status of zero indicates success, and a nonzero value indicates failure. Examples: # Output "sort". basename /usr/bin/sort # Output "stdio". basename include/stdio.h .h dirname: Strip non-directory suffix from a file name dirname directory components, printing stripping non-directory suffix non-directory suffix, stripping dirname prints all but the final slash-delimited component of a string (presumably a file name). Synopsis: dirname name If name is a single component, dirname prints ‘.’ (meaning the current directory). Together, basename and dirname are designed such that if ‘ls "$name"’ succeeds, then the command sequence ‘cd "$(dirname "$name")"; ls "$(basename "$name")"’ will, too. This works for everything except file names containing a trailing newline. POSIX allows the implementation to define the results if name is ‘//’. With GNU dirname, the result is ‘//’ on platforms where // is distinct from /, and ‘/’ on platforms where there is no difference. The only options are and . See . An exit status of zero indicates success, and a nonzero value indicates failure. Examples: # Output "/usr/bin". dirname /usr/bin/sort # Output ".". dirname stdio.h pathchk: Check file name portability pathchk file names, checking validity and portability valid file names, checking for portable file names, checking for pathchk checks portability of file names. Synopsis: pathchk [option]… name For each name, pathchk prints a message if any of these conditions is true: One of the existing directories in name does not have search(execute) permission, The length of name is larger than the maximum supported by theoperating system. The length of one component of name is longer thanits file system's maximum. A nonexistent name is not an error, so long a file with that name could be created under the above conditions. The program accepts the following options. Also see . Options must precede operands. -p -pInstead of performing checks based on the underlying file system,print a message if any of these conditions is true: A file name is empty. The length of a file name or one of its components exceeds thePOSIX minimum limits for portability. A file name contains a character outside the portable file namecharacter set, namely, the ASCII letters and digits, ‘-’,‘.’, ‘/’, and ‘_’. -P -PPrint a message if a file name is empty, or if it contains a componentthat begins with ‘-’. --portability –portabilityPrint a message if a file name is not portable to all POSIXhosts. This option is equivalent to ‘-p -P’. exit status of pathchk Exit status: 0 if all specified file names passed all checks, 1 otherwise. Working context working context commands for printing the working context This section describes commands that display or alter the context in which you are working: the current directory, the terminal settings, and so forth. See also the user-related commands in the next section. pwd: Print working directory pwd print name of current directory current working directory, printing working directory, printing symbolic links and pwd pwd prints the fully resolved name of the current directory. That is, all components of the printed name will be actual directory names—none will be symbolic links. conflicts with shell built-ins built-in shell commands, conflicts with Because most shells have a built-in pwd command, using an unadorned pwd in a script or interactively may get you different functionality than that described here. The only options are a lone or . See . An exit status of zero indicates success, and a nonzero value indicates failure. stty: Print or change terminal characteristics stty change or print terminal settings terminal settings line settings of terminal stty prints or changes terminal characteristics, such as baud rate. Synopses: stty [option] [setting]… stty [option] If given no line settings, stty prints the baud rate, line discipline number (on systems that support it), and line settings that have been changed from the values set by ‘stty sane’. By default, mode reading and setting are performed on the tty line connected to standard input, although this can be modified by the option. stty accepts many non-option arguments that change aspects of the terminal line operation, as described below. The program accepts the following options. Also see . -a’‘--all -a –allPrint all current settings in human-readable form. This option may notbe used in combination with any line settings. -F device’‘--file=device -F –fileSet the line opened by the file name specified in device instead ofthe tty line connected to standard input. This option is necessarybecause opening a POSIX tty requires use of the O_NONDELAY flag toprevent a POSIX tty from blocking until the carrier detect line is high ifthe clocal flag is not set. Hence, it is not always possibleto allow the shell to open the device in the traditional manner. -g’‘--save -g –save machine-readable stty outputPrint all current settings in a form that can be used as an argument toanother stty command to restore the current settings. This optionmay not be used in combination with any line settings. Many settings can be turned off by preceding them with a ‘-’. Such arguments are marked below with “May be negated” in their description. The descriptions themselves refer to the positive case, that is, when not negated (unless stated otherwise, of course). Some settings are not available on all POSIX systems, since they use extensions. Such arguments are marked below with “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. An exit status of zero indicates success, and a nonzero value indicates failure. Control settings control settings Control settings: parenb parenb two-way parityGenerate parity bit in output and expect parity bit in input.May be negated. parodd parodd odd parity even paritySet odd parity (even if negated). May be negated. cs5’‘cs6’‘cs7’‘cs8 csn character size eight-bit charactersSet character size to 5, 6, 7, or 8 bits. hup’‘hupcl hup[cl]Send a hangup signal when the last process closes the tty. May benegated. cstopb cstopb stop bitsUse two stop bits per character (one if negated). May be negated. cread creadAllow input to be received. May be negated. clocal clocal modem controlDisable modem control signals. May be negated. crtscts crtscts hardware flow control flow control, hardware RTS/CTS flow controlEnable RTS/CTS flow control. Non-POSIX. May be negated. Input settings input settings ignbrk ignbrk breaks, ignoringIgnore break characters. May be negated. brkint brkint breaks, cause interruptsMake breaks cause an interrupt signal. May be negated. ignpar ignpar parity, ignoringIgnore characters with parity errors. May be negated. parmrk parmrk parity errors, markingMark parity errors (with a 255-0-character sequence). May be negated. inpck inpckEnable input parity checking. May be negated. istrip istrip eight-bit inputClear high (8th) bit of input characters. May be negated. inlcr inlcr newline, translating to returnTranslate newline to carriage return. May be negated. igncr igncr return, ignoringIgnore carriage return. May be negated. icrnl icrnl return, translating to newlineTranslate carriage return to newline. May be negated. iutf8 iutf8 input encoding, UTF-8Assume input characters are UTF-8 encoded. May be negated. ixon ixon C-s/C-q flow control XON/XOFF flow controlEnable XON/XOFF flow control (that is, CTRL-S/CTRL-Q). Maybe negated. ixoff’‘tandem ixoff tandem software flow control flow control, softwareEnable sending of stop character when the system input bufferis almost full, and start character when it becomes almostempty again. May be negated. iuclc iuclc uppercase, translating to lowercaseTranslate uppercase characters to lowercase. Non-POSIX. May benegated. ixany ixanyAllow any character to restart output (only the start characterif negated). Non-POSIX. May be negated. imaxbel imaxbel beeping at input buffer fullEnable beeping and not flushing input buffer if a character arriveswhen the input buffer is full. Non-POSIX. May be negated. Output settings output settings These arguments specify output-related operations. opost opostPostprocess output. May be negated. olcuc olcuc lowercase, translating to outputTranslate lowercase characters to uppercase. Non-POSIX. May benegated. ocrnl ocrnl return, translating to newlineTranslate carriage return to newline. Non-POSIX. May be negated. onlcr onlcr newline, translating to crlfTranslate newline to carriage return-newline. Non-POSIX. May benegated. onocr onocrDo not print carriage returns in the first column. Non-POSIX.May be negated. onlret onlretNewline performs a carriage return. Non-POSIX. May be negated. ofill ofill pad instead of timing for delayingUse fill (padding) characters instead of timing for delays. Non-POSIX.May be negated. ofdel ofdel pad characterUse delete characters for fill instead of null characters. Non-POSIX.May be negated. nl1’‘nl0 nlnNewline delay style. Non-POSIX. cr3’‘cr2’‘cr1’‘cr0 crnCarriage return delay style. Non-POSIX. tab3’‘tab2’‘tab1’‘tab0 tabnHorizontal tab delay style. Non-POSIX. bs1’‘bs0 bsnBackspace delay style. Non-POSIX. vt1’‘vt0 vtnVertical tab delay style. Non-POSIX. ff1’‘ff0 ffnForm feed delay style. Non-POSIX. Local settings local settings isig isigEnable interrupt, quit, and suspend specialcharacters. May be negated. icanon icanonEnable erase, kill, werase, and rprntspecial characters. May be negated. iexten iextenEnable non-POSIX special characters. May be negated. echo echoEcho input characters. May be negated. echoe’‘crterase echoe crteraseEcho erase characters as backspace-space-backspace. May benegated. echok echok newline echoing after killEcho a newline after a kill character. May be negated. echonl echonl newline, echoingEcho newline even if not echoing other characters. May be negated. noflsh noflsh flushing, disablingDisable flushing after interrupt and quit specialcharacters. May be negated. xcase xcase case translationEnable input and output of uppercase characters by preceding theirlowercase equivalents with ‘\’, when icanon is set.Non-POSIX. May be negated. tostop tostop background jobs, stopping at terminal writeStop background jobs that try to write to the terminal. Non-POSIX.May be negated. echoprt’‘prterase echoprt prteraseEcho erased characters backward, between ‘\’ and ‘/’.Non-POSIX. May be negated. echoctl’‘ctlecho echoctl ctlecho control characters, using ‘^c hat notation for control charactersEcho control characters in hat notation (‘^c’) insteadof literally. Non-POSIX. May be negated. echoke’‘crtkill echoke crtkillEcho the kill special character by erasing each character onthe line as indicated by the echoprt and echoe settings,instead of by the echoctl and echok settings. Non-POSIX.May be negated. Combination settings combination settings Combination settings: evenp evenp parity paritySame as parenb -parodd cs7. May be negated. If negated, sameas -parenb cs8. oddp oddpSame as parenb parodd cs7. May be negated. If negated, sameas -parenb cs8. nl nlSame as -icrnl -onlcr. May be negated. If negated, same asicrnl -inlcr -igncr onlcr -ocrnl -onlret. ek ekReset the erase and kill special characters to their defaultvalues. sane saneSame as: cread -ignbrk brkint -inlcr -igncr icrnl -ixoff -iuclc -ixany imaxbel opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke and also sets all special characters to their default values. cooked cookedSame as brkint ignpar istrip icrnl ixon opost isig icanon, plussets the eof and eol characters to their default valuesif they are the same as the min and time characters.May be negated. If negated, same as raw. raw rawSame as: -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -opost -isig -icanon -xcase min 1 time 0 May be negated. If negated, same as cooked. cbreak cbreakSame as . May be negated. If negated, same asicanon. pass8 pass8 eight-bit charactersSame as -parenb -istrip cs8. May be negated. If negated,same as parenb istrip cs7. litout litoutSame as . May be negated.If negated, same as parenb istrip opost cs7. decctlq decctlqSame as . Non-POSIX. May be negated. tabs tabsSame as tab0. Non-POSIX. May be negated. If negated, sameas tab3. lcase’‘LCASE lcase LCASESame as xcase iuclc olcuc. Non-POSIX. May be negated. crt crtSame as echoe echoctl echoke. dec decSame as echoe echoctl echoke -ixany intr ^C erase ^? kill C-u. Special characters special characters characters, special The special characters' default values vary from system to system. They are set with the syntax ‘name value’, where the names are listed below and the value can be given either literally, in hat notation (‘^c’), or as an integer which may start with ‘0x’ to indicate hexadecimal, ‘0’ to indicate octal, or any other digit to indicate decimal. disabling special characters u, and disabling special characters For GNU stty, giving a value of ^- or undef disables that special character. (This is incompatible with Ultrix stty, which uses a value of ‘u’ to disable a special character. GNU stty treats a value ‘u’ like any other, namely to set that special character to U.) intr intrSend an interrupt signal. quit quitSend a quit signal. erase eraseErase the last character typed. kill killErase the current line. eof eofSend an end of file (terminate the input). eol eolEnd the line. eol2 eol2Alternate character to end the line. Non-POSIX. swtch swtchSwitch to a different shell layer. Non-POSIX. start startRestart the output after stopping it. stop stopStop the output. susp suspSend a terminal stop signal. dsusp dsuspSend a terminal stop signal after flushing the input. Non-POSIX. rprnt rprntRedraw the current line. Non-POSIX. werase weraseErase the last word typed. Non-POSIX. lnext lnextEnter the next character typed literally, even if it is a specialcharacter. Non-POSIX. Special settings special settings min n minSet the minimum number of characters that will satisfy a read untilthe time value has expired, when is set. time n timeSet the number of tenths of a second before reads time out if the minimumnumber of characters have not been read, when is set. ispeed n ispeedSet the input speed to n. ospeed n ospeedSet the output speed to n. rows n rowsTell the tty kernel driver that the terminal has n rows. Non-POSIX. cols n’‘columns n cols columnsTell the kernel that the terminal has n columns. Non-POSIX. size size LINES COLUMNSPrint the number of rows and columns that the kernel thinks theterminal has. (Systems that don't support rows and columns in the kerneltypically use the environment variables LINES and COLUMNSinstead; however, GNU stty does not know anything about them.)Non-POSIX. line n lineUse line discipline n. Non-POSIX. speed speedPrint the terminal speed. n baud rate, setting Set the input and output speeds to n. n can be oneof: 0 50 75 110 134 134.5 150 200 300 600 1200 1800 2400 4800 960019200 38400 exta extb. exta is the same as19200; extb is the same as 38400. 0 hangs up the line if is set. printenv: Print all or some environment variables printenv printing all or some environment variables environment variables, printing printenv prints environment variable values. Synopsis: printenv [option] [variable]… If no variables are specified, printenv prints the value of every environment variable. Otherwise, it prints the value of each variable that is set, and nothing for those that are not set. The only options are a lone or . See . exit status of printenv Exit status: 0 if all variables specified were found 1 if at least one specified variable was not found 2 if a write error occurred tty: Print file name of terminal on standard input tty print terminal file name terminal file name, printing tty prints the file name of the terminal connected to its standard input. It prints ‘not a tty’ if standard input is not a terminal. Synopsis: tty [option]… The program accepts the following option. Also see . -s’‘--silent’‘--quiet -s –silent –quietPrint nothing; only return an exit status. exit status of tty Exit status: 0 if standard input is a terminal 1 if standard input is not a terminal 2 if given incorrect arguments 3 if a write error occurs User information user information, commands for commands for printing user information This section describes commands that print user-related information: logins, groups, and so forth. id: Print user identity id real user and group IDs, printing effective user and group IDs, printing printing real and effective user and group IDs id prints information about the given user, or the process running it if no user is specified. Synopsis: id [option]… [username] By default, it prints the real user ID, real group ID, effective user ID if different from the real user ID, effective group ID if different from the real group ID, and supplemental group IDs. Each of these numeric values is preceded by an identifying string and followed by the corresponding user or group name in parentheses. The options cause id to print only part of the above information. Also see . -g’‘--group -g –groupPrint only the group ID. -G’‘--groups -G –groupsPrint only the group ID and the supplementary groups. -n’‘--name -n –namePrint the user or group name instead of the ID number. Requires, , or . -r’‘--real -r –realPrint the real, instead of effective, user or group ID. Requires, , or . -u’‘--user -u –userPrint only the user ID. An exit status of zero indicates success, and a nonzero value indicates failure. logname: Print current login name logname printing user's login name login name, printing user name, printing utmp logname prints the calling user's name, as found in a system-maintained file (often /var/run/utmp or /etc/utmp), and exits with a status of 0. If there is no entry for the calling process, logname prints an error message and exits with a status of 1. The only options are and . See . An exit status of zero indicates success, and a nonzero value indicates failure. whoami: Print effective user ID whoami effective user ID, printing printing the effective user ID whoami prints the user name associated with the current effective user ID. It is equivalent to the command ‘id -un’. The only options are and . See . An exit status of zero indicates success, and a nonzero value indicates failure. groups: Print group names a user is in groups printing groups a user is in supplementary groups, printing groups prints the names of the primary and any supplementary groups for each given username, or the current process if no names are given. If more than one name is given, the name of each user is printed before the list of that user's groups. Synopsis: groups [username]… The group lists are equivalent to the output of the command ‘id -Gn’. The only options are and . See . An exit status of zero indicates success, and a nonzero value indicates failure. users: Print login names of users currently logged in users printing current usernames usernames, printing current login sessions, printing users with users prints on a single line a blank-separated list of user names of users currently logged in to the current host. Each user name corresponds to a login session, so if a user has more than one login session, that user's name will appear the same number of times in the output. Synopsis: users [file] utmp wtmp With no file argument, users extracts its information from a system-maintained file (often /var/run/utmp or /etc/utmp). If a file argument is given, users uses that file instead. A common choice is /var/log/wtmp. The only options are and . See . An exit status of zero indicates success, and a nonzero value indicates failure. who: Print who is currently logged in who printing current user information information, about current users who prints information about users who are currently logged on. Synopsis: who [option] [file] [am i] terminal lines, currently used login time remote hostname If given no non-option arguments, who prints the following information for each user currently logged on: login name, terminal line, login time, and remote hostname or X display. utmp wtmp If given one non-option argument, who uses that instead of a default system-maintained file (often /var/run/utmp or /etc/utmp) as the name of the file containing the record of users logged on. /var/log/wtmp is commonly given as an argument to who to look at who has previously logged on. am i who am i If given two non-option arguments, who prints only the entry for the user running it (determined from its standard input), preceded by the hostname. Traditionally, the two arguments given are ‘am i’, as in ‘who am i’. TZ Time stamps are listed according to the time zone rules specified by the TZ environment variable, or by the system default rules if TZ is not set. See See section ``Specifying the Time Zone with @env{TZ}'' in The GNU C Library. The program accepts the following options. Also see . -a’‘--all -a –allSame as ‘-b -d --login -p -r -t -T -u’. -b’‘--boot -b –bootPrint the date and time of last system boot. -d’‘--dead -d –deadPrint information corresponding to dead processes. -H’‘--heading -H –headingPrint column headings. -m -mSame as ‘who am i’. -q’‘--count -q –countPrint only the login names and the number of users logged on.Overrides all other options. -s -sIgnored; for compatibility with other versions of who. -u -u idle timeAfter the login time, print the number of hours and minutes that theuser has been idle. ‘.’ means the user was active in the last minute.‘old’ means the user has been idle for more than 24 hours. -l’‘--login -l –loginList only the entries that correspond to processes via which thesystem is waiting for a user to login. The user name is always ‘LOGIN’. --lookup –lookupAttempt to canonicalize hostnames found in utmp through a DNS lookup. Thisis not the default because it can cause significant delays on systems withautomatic dial-up internet access. -H’‘--heading -H –headingPrint a line of column headings. -w’‘-T’‘--mesg’‘--message’‘--writable -w -T –mesg –message –writable message status write, allowedAfter each login name print a character indicating the user's message status: +’ allowing write messages ‘-’ disallowing write messages ‘?’ cannot find terminal device An exit status of zero indicates success, and a nonzero value indicates failure. System context system context context, system commands for system context This section describes commands that print or change system-wide information. date: Print or set system date and time date time, printing or setting printing the current time Synopses: date [option]… [+format] date [-u|--utc|--universal] [ MMDDhhmm[[CC]YY][.ss] ] LC_TIME Invoking date with no format argument is equivalent to invoking it with a default format that depends on the LC_TIME locale category. In the default C locale, this format is ‘'+%a %b %e %H:%M:%S %Z %Y'’, so the output looks like ‘Thu Mar 3 13:47:51 PST 2005’. TZ Normally, date uses the time zone rules indicated by the TZ environment variable, or the system default rules if TZ is not set. See See section ``Specifying the Time Zone with @env{TZ}'' in The GNU C Library. strftime and date time formats formatting times If given an argument that starts with a ‘+’, date prints the current date and time (or the date and time specified by the option, see below) in the format defined by that argument, which is similar to that of the strftime function. Except for conversion specifiers, which start with ‘%’, characters in the format string are printed unchanged. The conversion specifiers are described below. An exit status of zero indicates success, and a nonzero value indicates failure. Time conversion specifiers time conversion specifiers conversion specifiers, time date conversion specifiers related to times. %Hhour (‘00’…‘23’) %Ihour (‘01’…‘12’) %khour (‘ 0’…‘23’).This is a GNU extension. %lhour (‘ 1’…‘12’).This is a GNU extension. %Mminute (‘00’…‘59’) %Nnanoseconds (‘000000000’…‘999999999’).This is a GNU extension. %plocale's equivalent of either ‘AM’ or ‘PM’;blank in many locales.Noon is treated as ‘PM’ and midnight as ‘AM’. %Plike ‘%p’, except lower case.This is a GNU extension. %rlocale's 12-hour clock time (e.g., ‘11:11:04 PM’) %R24-hour hour and minute. Same as ‘%H:%M’.This is a GNU extension. %s epoch, seconds since seconds since the epoch beginning of timeseconds since the epoch, i.e., since 1970-01-01 00:00:00 UTC.Leap seconds are not counted unless leap second support is available.See , for examples.This is a GNU extension. %Ssecond (‘00’…‘60’).This may be ‘60’ if leap seconds are supported. %T24-hour hour, minute, and second. Same as ‘%H:%M:%S’. %Xlocale's time representation (e.g., ‘23:13:48’) %zRFC 2822/ISO 8601 style numeric time zone(e.g., ‘-0600’ or ‘+0530’), or nothing if notime zone is determinable. This value reflects the numeric time zoneappropriate for the current time, using the time zone rules specifiedby the TZ environment variable.The time (and optionally, the time zone rules) can be overriddenby the option.This is a GNU extension. %:zRFC 3339/ISO 8601 style numeric time zone with‘:’ (e.g., ‘-06:00’ or ‘+05:30’), or nothing if no timezone is determinable.This is a GNU extension. %::zNumeric time zone to the nearest second with ‘:’ (e.g.,‘-06:00:00’ or ‘+05:30:00’), or nothing if no time zone isdeterminable.This is a GNU extension. %:::zNumeric time zone with ‘:’ using the minimum necessary precision(e.g., ‘-06’, ‘+05:30’, or ‘-04:56:02’), or nothing ifno time zone is determinable.This is a GNU extension. %Zalphabetic time zone abbreviation (e.g., ‘EDT’), or nothing if notime zone is determinable. See ‘%z’ for how it is determined. Date conversion specifiers date conversion specifiers conversion specifiers, date date conversion specifiers related to dates. %alocale's abbreviated weekday name (e.g., ‘Sun’) %Alocale's full weekday name, variable length (e.g., ‘Sunday’) %blocale's abbreviated month name (e.g., ‘Jan’) %Blocale's full month name, variable length (e.g., ‘January’) %clocale's date and time (e.g., ‘Thu Mar 3 23:05:25 2005’) %Ccentury. This is like ‘%Y’, except the last two digits are omitted.For example, it is ‘20’ if ‘%Y’ is ‘2000’,and is ‘-0’ if ‘%Y’ is ‘-001’.It is normally at least two characters, but it may be more. %dday of month (e.g., ‘01’) %Ddate; same as ‘%m/%d/%y %eday of month, space padded; same as ‘%_d %Ffull date in ISO 8601 format; same as ‘%Y-%m-%d’.This is a good choice for a date format, as it is standard andis easy to sort in the usual case where years are in the range0000…9999.This is a GNU extension. %gyear corresponding to the ISO week number, but without the century(range ‘00’ through ‘99’). This has the same format and valueas ‘%y’, except that if the ISO week number (see‘%V’) belongsto the previous or next year, that year is used instead.This is a GNU extension. %Gyear corresponding to the ISO week number. This has thesame format and value as ‘%Y’, except that if the ISOweek number (see‘%V’) belongs to the previous or next year, that year is usedinstead.It is normally useful only if ‘%V’ is also used;for example, the format ‘%G-%m-%d’ is probably a mistake,since it combines the ISO week number year with the conventional month and day.This is a GNU extension. %hsame as ‘%b %jday of year (‘001’…‘366’) %mmonth (‘01’…‘12’) %uday of week (‘1’…‘7’) with ‘1’ corresponding to Monday %Uweek number of year, with Sunday as the first day of the week(‘00’…‘53’).Days in a new year preceding the first Sunday are in week zero. %VISO week number, that is, theweek number of year, with Monday as the first day of the week(‘01’…‘53’).If the week containing January 1 has four or more days inthe new year, then it is considered week 1; otherwise, it is week 53 ofthe previous year, and the next week is week 1. (See the ISO 8601standard.) %wday of week (‘0’…‘6’) with 0 corresponding to Sunday %Wweek number of year, with Monday as first day of week(‘00’…‘53’).Days in a new year preceding the first Monday are in week zero. %xlocale's date representation (e.g., ‘12/31/99’) %ylast two digits of year (‘00’…‘99’) %Yyear. This is normally at least four characters, but it may be more.Year ‘0000’ precedes year ‘0001’, and year ‘-001’precedes year ‘0000’. Literal conversion specifiers literal conversion specifiers conversion specifiers, literal date conversion specifiers that produce literal strings. %%a literal % %na newline %ta horizontal tab Padding and other flags numeric field padding padding of numeric fields fields, padding numeric Unless otherwise specified, date normally pads numeric fields with zeros, so that, for 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 GNU extension, date recognizes any of the following optional flags after the ‘%’: -(hyphen) Do not pad the field; useful if the output is intended forhuman consumption. _(underscore) Pad with spaces; useful if you need a fixednumber of characters in the output, but zeros are too distracting. 0(zero) Pad with zeros even if the conversion specifierwould normally pad with spaces. ^Use upper case characters if possible. #Use opposite case characters if possible.A field that is normally upper case becomes lower case, and vice versa. Here are some examples of padding: date +%d/%m -d "Feb 1" => 01/02 date +%-d/%-m -d "Feb 1" => 1/2 date +%_d/%_m -d "Feb 1" => 1/ 2 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 is of the field has less than the specified number of characters, the result is written right adjusted and padded to the given size. For example, ‘%9B’ prints the right adjusted month name in a field of width 9. An optional modifier can follow the optional flag and width specification. The modifiers are: EUse the locale's alternate representation for date and time. Thismodifier applies to the ‘%c’, ‘%C’, ‘%x’, ‘%X’,‘%y’ and ‘%Y’ conversion specifiers. In a Japanese locale, forexample, ‘%Ex’ might yield a date format based on the JapaneseEmperors' reigns. OUse the locale's alternate numeric symbols for numbers. This modifierapplies only to numeric conversion specifiers. If the format supports the modifier but no alternate representation is available, it is ignored. Setting the time setting the time time setting appropriate privileges If given an argument that does not start with ‘+’, 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 and options may not be used with such an argument. The 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. The argument must consist entirely of digits, which have the following meaning: MMmonth DDday within month hhhour mmminute CCfirst two digits of year (optional) YYlast two digits of year (optional) sssecond (optional) The option also sets the system clock; see the next section. Options for date date options options for date The program accepts the following options. Also see . -d datestr’‘--date=datestr -d –date parsing date strings date strings, parsing arbitrary date strings, parsing yesterday tomorrow next day last dayDisplay the date and time specified in datestr instead of thecurrent date and time. datestr can be in almost any commonformat. It can contain month names, time zones, ‘am’ and ‘pm’,‘yesterday’, etc. For example, specifies the instant of time that is489,392,193 nanoseconds after February 27, 2004 at 2:19:13 PM in atime zone that is 5 hours and 30 minutes east of UTC.See . -f datefile’‘--file=datefile -f –fileParse each line in datefile as with and display theresulting date and time. If datefile is ‘-’, use standardinput. This is useful when you have many dates to process, because thesystem overhead of starting up the date executable many times canbe considerable. -r file’‘--reference=file -r –referenceDisplay the date and time of the last modification of file,instead of the current date and time. -R’‘--rfc-822’‘--rfc-2822 -R –rfc-822 –rfc-2822Display the date and time using the format ‘%a, %d %b %Y %H:%M:%S%z’, evaluated in the C locale so abbreviations are always in English.For example: Fri, 09 Sep 2005 13:51:39 -0700 This format conforms toInternetRFCs 2822 and822, thecurrent and previous standards for Internet email. --rfc-3339=timespec –rfc-3339=timespecDisplay the date using a format specified byInternetRFC 3339. This is a subset of the ISO 8601format, except that it also permits applications to use a space ratherthan a ‘T’ to separate dates from times. Unlike the otherstandard formats, RFC 3339 format is always suitable asinput for the () and () options, regardless of the current locale.The argument timespec specifies how much of the time to include.It can be one of the following: datePrint just the full-date, e.g., ‘2005-09-14’.This is equivalent to the format ‘%Y-%m-%d’. secondsPrint the full-date and full-time separated by a space, e.g.,‘2005-09-14 00:56:06+05:30’. The output ends with a numerictime-offset; here the ‘+05:30’ means that local time is fivehours and thirty minutes east of UTC. This is equivalent tothe format ‘%Y-%m-%d %H:%M:%S%:z’. nsLike ‘seconds’, but also print nanoseconds, e.g.,‘2005-09-14 00:56:06.998458565+05:30’.This is equivalent to the format ‘%Y-%m-%d %H:%M:%S.%N%:z’. -s datestr’‘--set=datestr -s –setSet the date and time to datestr. See above. -u’‘--utc’‘--universal -u –utc –universal Coordinated Universal Time UTC Greenwich Mean Time GMT TZUse Coordinated Universal Time (UTC) by operating as if theTZ environment variable were set to the string ‘UTC0’.CoordinatedUniversal Time is often called “Greenwich Mean Time” (gmt) forhistorical reasons. Examples of date examples of date Here are a few examples. Also see the documentation for the option in the previous section. To print the date of the day before yesterday: date --date='2 days ago' To print the date of the day three months and one day hence: date --date='3 months 1 day' To print the day of year of Christmas in the current year: date --date='25 Dec' +%j To print the current full month name and the day of the month: date '+%B %d' But this may not be what you want because for the first nine days ofthe month, the ‘%d’ expands to a zero-padded two-digit field,for example ‘date -d 1may '+%B %d'’ will print ‘May 01’. To print a date without the leading zero for one-digit daysof the month, you can use the (GNU extension)‘-’ flag to suppressthe padding altogether: date -d 1may '+%B %-d To print the current date and time in the format required by manynon-GNU versions of date when setting the system clock: date +%m%d%H%M%Y.%S To set the system clock forward by two minutes: date --set='+2 minutes' To print the date in RFC 2822 format,use ‘date --rfc-2822’. Here is some example output: Fri, 09 Sep 2005 13:51:39 -0700 To convert a date string to the number of seconds since the epoch(which is 1970-01-01 00:00:00 UTC), use the option withthe ‘%s’ format. That can be useful in sorting and/or graphingand/or comparing data by date. The following command outputs thenumber of the seconds since the epoch for the time two minutes after theepoch: date --date='1970-01-01 00:02:00 +0000' +%s 120 If you do not specify time zone information in the date string,date uses your computer's idea of the time zone wheninterpreting the string. For example, if your computer's time zone isthat of Cambridge, Massachusetts, which was then 5 hours (i.e., 18,000seconds) behind UTC: # local time zone used date --date='1970-01-01 00:02:00' +%s 18120 If you're sorting or graphing dated data, your raw date values may berepresented as seconds since the epoch. But few people can look atthe date ‘946684800’ and casually note “Oh, that's the first secondof the year 2000 in Greenwich, England.” date --date='2000-01-01 UTC' +%s 946684800 An alternative is to use the () option.Then you may omit ‘UTC’ from the date string. Although thisproduces the same result for ‘%s’ and many other format sequences,with a time zone offset different from zero, it would give a differentresult for zone-dependent formats like ‘%z’. date -u --date=2000-01-01 +%s 946684800 To convert such an unwieldy number of seconds back toa more readable form, use a command like this: # local time zone used date -d '1970-01-01 UTC 946684800 seconds' +"%Y-%m-%d %T %z" 1999-12-31 19:00:00 -0500 Or if you do not mind depending on the ‘@’ feature present sincecoreutils 5.3.0, you could shorten this to: date -d @946684800 +"%F %T %z" 1999-12-31 19:00:00 -0500 Often it is better to output UTC-relative date and time: date -u -d '1970-01-01 946684800 seconds' +"%Y-%m-%d %T %z" 2000-01-01 00:00:00 +0000 uname: Print system information uname print system information system information, printing uname prints information about the machine and operating system it is run on. If no options are given, uname acts as if the option were given. Synopsis: uname [option]… If multiple options or are given, the selected information is printed in this order: kernel-name nodename kernel-release kernel-version machine processor hardware-platform operating-system The information may contain internal spaces, so such output cannot be parsed reliably. In the following example, release is ‘2.2.18ss.e820-bda652a #4 SMP Tue Jun 5 11:24:08 PDT 2001’: uname -a => Linux dum 2.2.18 #4 SMP Tue Jun 5 11:24:08 PDT 2001 i686 unknown unknown GNU/Linux The program accepts the following options. Also see . -a’‘--all -a –allPrint all of the below information, except omit the processor typeand the hardware platform name if they are unknown. -i’‘--hardware-platform -i –hardware-platform implementation, hardware hardware platform platform, hardwarePrint the hardware platform name(sometimes called the hardware implementation).Print ‘unknown’ if the kernel does not make this informationeasily available, as is the case with Linux kernels. -m’‘--machine -m –machine machine type hardware class hardware typePrint the machine hardware name (sometimes called the hardware classor hardware type). -n’‘--nodename -n –nodename hostname node name network node namePrint the network node hostname. -p’‘--processor -p –processor host processor typePrint the processor type (sometimes called the instruction setarchitecture or ISA).Print ‘unknown’ if the kernel does not make this informationeasily available, as is the case with Linux kernels. -o’‘--operating-system -o –operating-system operating system namePrint the name of the operating system. -r’‘--kernel-release -r –kernel-release kernel release release of kernelPrint the kernel release. -s’‘--kernel-name -s –kernel-name kernel name name of kernelPrint the kernel name.POSIX 1003.1-2001 (see ) calls this“the implementation of the operating system”, because thePOSIX specification itself has no notion of “kernel”.The kernel name might be the same as the operating system name printedby the or option, but it mightdiffer. Some operating systems (e.g., FreeBSD, HP-UX) have the samename as their underlying kernels; others (e.g., GNU/Linux, Solaris)do not. -v’‘--kernel-version -v –kernel-version kernel version version of kernelPrint the kernel version. An exit status of zero indicates success, and a nonzero value indicates failure. hostname: Print or set system name hostname setting the hostname printing the hostname system name, printing appropriate privileges With no arguments, hostname prints the name of the current host system. With one argument, it sets the current host name to the specified string. You must have appropriate privileges to set the host name. Synopsis: hostname [name] The only options are and . See . An exit status of zero indicates success, and a nonzero value indicates failure. hostid: Print numeric host identifier. hostid printing the host identifier hostid prints the numeric identifier of the current host in hexadecimal. This command accepts no arguments. The only options are and . See . For example, here's what it prints on one system I use: $ hostid 1bac013d On that system, the 32-bit quantity happens to be closely related to the system's Internet address, but that isn't always the case. An exit status of zero indicates success, and a nonzero value indicates failure. Modified command invocation modified command invocation invocation of commands, modified commands for invoking other commands This section describes commands that run other commands in some context different than the current one: a modified environment, as a different user, etc. chroot: Run a command with a different root directory chroot running a program in a specified root directory root directory, running a program in a specified chroot runs a command with a specified root directory. On many systems, only the super-user can do this. Synopses: chroot newroot [command [args]…] chroot option Ordinarily, file names are looked up starting at the root of the directory structure, i.e., /. chroot changes the root to the directory newroot (which must exist) and then runs command with optional args. If command is not specified, the default is the value of the SHELL environment variable or /bin/sh if not set, invoked with the option. command must not be a special built-in utility (see ). The only options are and . See . Options must precede operands. Here are a few tips to help avoid common problems in using chroot. To start with a simple example, make command refer to a statically linked binary. If you were to use a dynamically linked executable, then you'd have to arrange to have the shared libraries in the right place under your new root directory. For example, if you create a statically linked ls executable, and put it in /tmp/empty, you can run this command as root: $ chroot /tmp/empty /ls -Rl / Then you'll see output like this: /: total 1023 -rwxr-xr-x 1 0 0 1041745 Aug 16 11:17 ls If you want to use a dynamically linked executable, say bash, then first run ‘ldd bash’ to see what shared objects it needs. Then, in addition to copying the actual binary, also copy the listed files to the required positions under your intended new root directory. Finally, if the executable requires any other files (e.g., data, state, device files), copy them into place, too. exit status of chroot Exit status: 1 if chroot itself fails 126 if command is found but cannot be invoked 127 if command cannot be found the exit status of command otherwise env: Run a command in a modified environment env environment, running a program in a modified modified environment, running a program in a running a program in a modified environment env runs a command with a modified environment. Synopses: env [option]… [name=value]… [command [args]…] env Operands of the form ‘variable=value’ set the environment variable variable to value value. value may be empty (‘variable=’). Setting a variable to an empty value is different from unsetting it. 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 ‘=’ and the null character (ASCII nul). However, it is wise to limit yourself to names that 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. PATH The first operand that does not contain the character ‘=’ specifies the program to invoke; it is searched for according to the PATH environment variable. Any remaining arguments are passed as arguments to that program. The program should not be a special built-in utility (see ). environment, printing If no command name is specified following the environment specifications, the resulting environment is printed. This is like specifying the printenv program. The program accepts the following options. Also see . Options must precede operands. -u name’‘--unset=name -u –unsetRemove variable name from the environment, if it was in theenvironment. -’‘-i’‘--ignore-environment - -i –ignore-environmentStart with an empty environment, ignoring the inherited environment. exit status of env Exit status: 0 if no command is specified and the environment is output 1 if env itself fails 126 if command is found but cannot be invoked 127 if command cannot be found the exit status of command otherwise nice: Run a command with modified niceness nice niceness scheduling, affecting appropriate privileges nice prints or modifies a process's niceness, a parameter that affects whether the process is scheduled favorably. Synopsis: nice [option]… [command [arg]…] If no arguments are given, nice prints the current niceness. Otherwise, nice runs the given command with its niceness adjusted. By default, its niceness is incremented by 10. Nicenesses range at least from −20 (resulting in the most favorable scheduling) through 19 (the least favorable). Some systems may have a wider range of nicenesses; 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. 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, POSIX defines the behavior of nice in terms of a nice value, which is the nonnegative difference between a niceness and the minimum niceness. Though nice conforms to POSIX, its documentation and diagnostics use the term “niceness” for compatibility with historical practice. command must not be a special built-in utility (see ). conflicts with shell built-ins built-in shell commands, conflicts with Because many shells have a built-in nice command, using an unadorned nice in a script or interactively may get you different functionality than that described here. The program accepts the following option. Also see . Options must precede operands. -n adjustment’‘--adjustment=adjustment -n –adjustmentAdd adjustment instead of 10 to the command's niceness. Ifadjustment is negative and you lack appropriate privileges,nice issues a warning but otherwise acts as if you specifieda zero adjustment.For compatibility nice also supports an obsoleteoption syntax . New scripts should use instead. exit status of nice Exit status: 0 if no command is specified and the niceness is output 1 if nice itself fails 126 if command is found but cannot be invoked 127 if command cannot be found the exit status of command otherwise It is sometimes useful to run a non-interactive program with reduced niceness. $ nice factor 4611686018427387903 Since nice prints the current niceness, you can invoke it through itself to demonstrate how it works. The default behavior is to increase the niceness by ‘10’: $ nice 0 $ nice nice 10 $ nice -n 10 nice 10 The adjustment is relative to the current niceness. In the next example, the first nice invocation runs the second one with niceness 10, and it in turn runs the final one with a niceness that is 3 more: $ nice nice -n 3 nice 13 Specifying a niceness larger than the supported range is the same as specifying the maximum supported value: $ nice -n 10000000000 nice 19 Only a privileged user may run a process with lower niceness: $ nice -n -1 nice nice: cannot set niceness: Permission denied 0 $ sudo nice -n -1 nice -1 nohup: Run a command immune to hangups nohup hangups, immunity to immunity to hangups logging out and continuing to run nohup.out nohup runs the given command with hangup signals ignored, so that the command can continue running in the background after you log out. Synopsis: nohup command [arg]… If standard input is a terminal, it is redirected from /dev/null so that terminal sessions do not mistakenly consider the terminal to be used by the command. This is a GNU extension; programs intended to be portable to non-GNU hosts should use ‘nohup command [arg]… </dev/null’ instead. nohup.out If standard output is a terminal, the command's standard output is appended to the file nohup.out; if that cannot be written to, it is appended to the file $HOME/nohup.out; and if that cannot be written to, the command is not run. Any nohup.out or $HOME/nohup.out file created by nohup is made readable and writable only to the user, regardless of the current umask settings. If standard error is a terminal, it is normally redirected to the same file descriptor as the (possibly-redirected) standard output. However, if standard output is closed, standard error terminal output is instead appended to the file nohup.out or $HOME/nohup.out as above. nohup does not automatically put the command it runs in the background; you must do that explicitly, by ending the command line with an ‘&’. Also, nohup does not alter the niceness of command; use nice for that, e.g., ‘nohup nice command’. command must not be a special built-in utility (see ). The only options are and . See . Options must precede operands. exit status of nohup Exit status: 126 if command is found but cannot be invoked 127 if nohup itself fails or if command cannot be found the exit status of command otherwise su: Run a command with substitute user and group ID su substitute user and group IDs user ID, switching super-user, becoming root, becoming su allows one user to temporarily become another user. It runs a command (often an interactive shell) with the real and effective user ID, group ID, and supplemental groups of a given user. Synopsis: su [option]… [user [arg]…] passwd entry, and su shell /bin/sh /etc/passwd If no user is given, the default is root, the super-user. The shell to use is taken from user's passwd entry, or /bin/sh if none is specified there. If user has a password, su prompts for the password unless run by a user with effective user ID of zero (the super-user). HOME SHELL USER LOGNAME login shell By default, su does not change the current directory. It sets the environment variables HOME and SHELL from the password entry for user, and if user is not the super-user, sets USER and LOGNAME to user. By default, the shell is not a login shell. Any additional args are passed as additional arguments to the shell. GNU su does not treat /bin/sh or any other shells specially (e.g., by setting argv[0] to , passing only to certain shells, etc.). syslog su can optionally be compiled to use syslog to report failed, and optionally successful, su attempts. (If the system supports syslog.) However, GNU su does not check if the user is a member of the wheel group; see below. The program accepts the following options. Also see . -c command’‘--command=command -c –commandPass command, a single command line to run, to the shell witha option instead of starting an interactive shell. -f’‘--fast -f –fast .cshrc file name pattern expansion, disabled globbing, disabledPass the option to the shell. This probably only makes senseif the shell run is csh or tcsh, for which the option prevents reading the startup file (.cshrc). WithBourne-like shells, the option disables file name patternexpansion (globbing), which is not likely to be useful. -’‘-l’‘--login - -l –login TERM PATH login shell, creatingMake the shell a login shell. This means the following. Unset allenvironment variables except TERM, HOME, and SHELL(which are set as described above), and USER and LOGNAME(which are set, even for the super-user, as described above), and setPATH to a compiled-in default value. Change to user's homedirectory. Prepend ‘-’ to the shell's name, intended to make itread its login startup file(s). -m’‘-p’‘--preserve-environment -m -p –preserve-environment environment, preserving /etc/shells restricted shellDo not change the environment variables HOME, USER,LOGNAME, or SHELL. Run the shell given in the environmentvariable SHELL instead of the shell from user's passwdentry, unless the user running su is not the super-user anduser's shell is restricted. A restricted shell is one thatis not listed in the file /etc/shells, or in a compiled-in listif that file does not exist. Parts of what this option does can beoverridden by and . -s shell’‘--shell=shell -s –shellRun shell instead of the shell from user's passwd entry,unless the user running su is not the super-user and user'sshell is restricted (see just above). exit status of su Exit status: 1 if su itself fails 126 if subshell is found but cannot be invoked 127 if subshell cannot be found the exit status of the subshell otherwise wheel group, not supported group wheel, not supported fascism Why GNU su does not support the ‘wheel’ group (This section is by Richard Stallman.) Twenex MIT AI lab Sometimes a few of the users try to hold total power over all the rest. For example, in 1984, a few users at the MIT AI lab decided to seize power by changing the operator password on the Twenex system and keeping it secret from everyone else. (I was able to thwart this coup and give power back to the users by patching the kernel, but I wouldn't know how to do that in Unix.) However, occasionally the rulers do tell someone. Under the usual su mechanism, once someone learns the root password who sympathizes with the ordinary users, he or she can tell the rest. The “wheel group” feature would make this impossible, and thus cement the power of the rulers. I'm on the side of the masses, not that of the rulers. If you are used to supporting the bosses and sysadmins in whatever they do, you might find this idea strange at first. Process control processes, commands for controlling commands for controlling processes kill: Send a signal to processes kill send a signal to processes The kill command sends a signal to processes, causing them to terminate or otherwise act upon receiving the signal in some way. Alternatively, it lists information about signals. Synopses: kill [-s signal | --signal signal | -signal] pid… kill [-l | --list | -t | --table] [signal]… The first form of the kill command sends a signal to all pid arguments. The default signal to send if none is specified is ‘TERM’. The special signal number ‘0’ does not denote a valid signal, but can be used to test whether the pid arguments specify processes to which a signal could be sent. If pid is positive, the signal is sent to the process with the process ID pid. If pid is zero, the signal is sent to all processes in the process group of the current process. If pid is −1, the signal is sent to all processes for which the user has permission to send a signal. If pid is less than −1, the signal is sent to all processes in the process group that equals the absolute value of pid. If pid is not positive, a system-dependent set of system processes is excluded from the list of processes to which the signal is sent. If a negative PID argument is desired as the first one, it should be preceded by . However, as a common extension to POSIX, is not required with ‘kill -signal -pid’. The following commands are equivalent: kill -15 -1 kill -TERM -1 kill -s TERM -- -1 kill -- -1 The first form of the kill command succeeds if every pid argument specifies at least one process that the signal was sent to. The second form of the kill command lists signal information. Either the or option, or the or option must be specified. Without any signal argument, all supported signals are listed. The output of or is a list of the signal names, one per line; if signal is already a name, the signal number is printed instead. The output of or is a table of signal numbers, names, and descriptions. This form of the kill command succeeds if all signal arguments are valid and if there is no output error. The kill command also supports the and options. See . A signal may be a signal name like ‘HUP’, or a signal number like ‘1’, or an exit status of a process terminated by the signal. A signal name can be given in canonical form or prefixed by ‘SIG’. The case of the letters is ignored, except for the option which must use upper case to avoid ambiguity with lower case option letters. The following signal names and numbers are supported on all POSIX compliant systems: HUP1. Hangup. INT2. Terminal interrupt. QUIT3. Terminal quit. ABRT6. Process abort. KILL9. Kill (cannot be caught or ignored). ALRM14. Alarm Clock. TERM15. Termination. Other supported signal names have system-dependent corresponding numbers. All systems conforming to POSIX 1003.1-2001 also support the following signals: BUSAccess to an undefined portion of a memory object. CHLDChild process terminated, stopped, or continued. CONTContinue executing, if stopped. FPEErroneous arithmetic operation. ILLIllegal Instruction. PIPEWrite on a pipe with no one to read it. SEGVInvalid memory reference. STOPStop executing (cannot be caught or ignored). TSTPTerminal stop. TTINBackground process attempting read. TTOUBackground process attempting write. URGHigh bandwidth data is available at a socket. USR1User-defined signal 1. USR2User-defined signal 2. POSIX 1003.1-2001 systems that support the XSI extension also support the following signals: POLLPollable event. PROFProfiling timer expired. SYSBad system call. TRAPTrace/breakpoint trap. VTALRMVirtual timer expired. XCPUCPU time limit exceeded. XFSZFile size limit exceeded. POSIX 1003.1-2001 systems that support the XRT extension also support at least eight real-time signals called ‘RTMIN’, ‘RTMIN+1’, …, ‘RTMAX-1’, ‘RTMAX’. Delaying delaying commands commands for delaying sleep: Delay for a specified time sleep delay for a specified time sleep pauses for an amount of time specified by the sum of the values of the command line arguments. Synopsis: sleep number[smhd]… time units Each argument is a number followed by an optional unit; the default is seconds. The units are: sseconds mminutes hhours ddays Historical implementations of sleep have required that number be an integer, and only accepted a single argument without a suffix. However, GNU sleep accepts arbitrary floating point numbers (using a period before any fractional digits). The only options are and . See . An exit status of zero indicates success, and a nonzero value indicates failure. Numeric operations numeric operations These programs do numerically-related operations. factor: Print prime factors factor prime factors factor prints prime factors. Synopses: factor [number]… factor option If no number is specified on the command line, factor reads numbers from standard input, delimited by newlines, tabs, or spaces. The only options are and . See . The algorithm it uses is not very sophisticated, so for some inputs factor runs for a long time. The hardest numbers to factor are the products of large primes. Factoring the product of the two largest 32-bit prime numbers takes about 80 seconds of CPU time on a 1.6 GHz Athlon. $ p=`echo '4294967279 * 4294967291'|bc` $ factor $p 18446743979220271189: 4294967279 4294967291 Similarly, it takes about 80 seconds for GNU factor (from coreutils-5.1.2) to “factor” the largest 64-bit prime: $ factor 18446744073709551557 18446744073709551557: 18446744073709551557 In contrast, factor factors the largest 64-bit number in just over a tenth of a second: $ factor `echo '2^64-1'|bc` 18446744073709551615: 3 5 17 257 641 65537 6700417 An exit status of zero indicates success, and a nonzero value indicates failure. seq: Print numeric sequences seq numeric sequences sequence of numbers seq prints a sequence of numbers to standard output. Synopses: seq [option]… last seq [option]… first last seq [option]… first increment last seq prints the numbers from first to last by increment. By default, each number is printed on a separate line. When increment is not specified, it defaults to ‘1’, even when first is larger than last. first also defaults to ‘1’. So seq 1 prints ‘1’, but seq 0 and seq 10 5 produce no output. Floating-point numbers may be specified (using a period before any fractional digits). The program accepts the following options. Also see . Options must precede operands. -f format’‘--format=format -f format –format=format formatting of numbers in seqPrint all numbers using format.format must contain exactly one of the ‘printf’-stylefloating point conversion specifications ‘%a’, ‘%e’,‘%f’, ‘%g’, ‘%A’, ‘%E’, ‘%F’, ‘%G’.The ‘%’ may be followed by zero or more flags taken from the set‘-+#0 '’, then an optional width containing one or more digits,then an optional precision consisting of a ‘.’ followed by zeroor more digits. format may also contain any number of ‘%%’conversion specifications. All conversion specifications have thesame meaning as with ‘printf’.The default format is derived from first, step, andlast. If these all use a fixed point decimal representation,the default format is ‘%.pf’, where p is the minimumprecision that can represent the output numbers exactly. Otherwise,the default format is ‘%g’. -s string’‘--separator=string separator for numbers in seqSeparate numbers with string; default is a newline.The output always terminates with a newline. -w’‘--equal-widthPrint all numbers with the same width, by padding with leading zeros.first, step, and last should all use a fixed pointdecimal representation.(To have other kinds of padding, use ). You can get finer-grained control over output with : $ seq -f '(%9.2E)' -9e5 1.1e6 1.3e6 (-9.00E+05) ( 2.00E+05) ( 1.30E+06) If you want hexadecimal integer output, you can use printf to perform the conversion: $ printf '%x\n' `seq 1048575 1024 1050623` fffff 1003ff 1007ff For very long lists of numbers, use xargs to avoid system limitations on the length of an argument list: $ seq 1000000 | xargs printf '%x\n' | tail -n 3 f423e f423f f4240 To generate octal output, use the printf %o format instead of %x. On most systems, seq can produce whole-number output for values up to at least 2^53. Larger integers are approximated. The details differ depending on your floating-point implementation, but a common case is that seq works with integers through 2^64, and larger integers may not be numerically correct: $ seq 18446744073709551616 1 18446744073709551618 18446744073709551616 18446744073709551616 18446744073709551618 Be careful when using seq with a fractional increment; otherwise you may see surprising results. Most people would expect to see 0.000003 printed as the last number in this example: $ seq -s ' ' 0 0.000001 0.000003 0.000000 0.000001 0.000002 But that doesn't happen on many systems because seq is implemented using binary floating point arithmetic (via the C long double type)—which means decimal fractions like 0.000001 cannot be represented exactly. That in turn means some nonintuitive conditions like 0.000001 * 3 > 0.000003 will end up being true. To work around that in the above example, use a slightly larger number as the last value: $ seq -s ' ' 0 0.000001 0.0000031 0.000000 0.000001 0.000002 0.000003 In general, when using an increment with a fractional part, where (last - first) / increment is (mathematically) a whole number, specify a slightly larger (or smaller, if increment is negative) value for last to ensure that last is the final value printed by seq. An exit status of zero indicates success, and a nonzero value indicates failure. File permissions Each file has a set of file mode bits that control the kinds of access that users have to that file. They can be represented either in symbolic form or as an octal number. Structure of File Mode Bits The file mode bits have two parts: the file permission bits, which control ordinary access to the file, and special mode bits, which affect only some files. There are three kinds of permissions that a user can have for a file: read permissionpermission to read the file. For directories, this means permission tolist the contents of the directory. write permissionpermission to write to (change) the file. For directories, this meanspermission to create and remove files in the directory. execute/search permissionpermission to execute the file (run it as a program). For directories,this means permission to access files in the directory. There are three categories of users who may have different permissions to perform any of the above operations on a file: the file's owner; other users who are in the file's group; everyone else. owner, default group owner, default Files are given an owner and group when they are created. Usually the owner is the current user and the group is the group of the directory the file is in, but this varies with the operating system, the file system the file is created on, and the way the file is created. You can change the owner and group of a file by using the chown and chgrp commands. In addition to the three sets of three permissions listed above, the file mode bits have three special components, which affect only executable files (programs) and, on most systems, directories: set-user-ID setuidSet the process's effective user ID to that of the file upon execution(called the set-user-ID bit, or sometimes the setuid bit).For directories on a few systems, give files created in the directorythe same owner as the directory, no matter who creates them, and setthe set-user-ID bit of newly-created subdirectories. set-group-ID setgidSet the process's effective group ID to that of the file upon execution(called the set-group-ID bit, or sometimes the setgid bit).For directories on most systems, give files created in the directorythe same group as the directory, no matter what group the user whocreates them is in, and set the set-group-ID bit of newly-createdsubdirectories. sticky swap space, saving text image in text image, saving in swap space restricted deletion flagPrevent unprivileged users from removing or renaming a file in a directoryunless they own the file or the directory; this is called therestricted deletion flag for the directory, and is commonlyfound on world-writable directories like /tmp.For regular files on some older systems, save the program's text image on theswap device so it will load more quickly when run; this is called thesticky bit. In addition to the file mode bits listed above, there may be file attributes specific to the file system, e.g., access control lists (ACLs), whether a file is compressed, whether a file can be modified (immutability), and whether a file can be dumped. These are usually set using programs specific to the file system. For example: ext2 On GNU and GNU/Linux the file attributes specific tothe ext2 file system are set using chattr. FFS On FreeBSD the file flags specific to the FFSfile system are set using chflags. Even if a file's mode bits allow an operation on that file, that operation may still fail, because: the file-system-specific attributes or flags do not permit it; or the file system is mounted as read-only. For example, if the immutable attribute is set on a file, it cannot be modified, regardless of the fact that you may have just run chmod a+w FILE. Symbolic Modes symbolic modes Symbolic modes represent changes to files' mode bits as operations on single-character symbols. They allow you to modify either all or selected parts of files' mode bits, optionally based on their previous values, and perhaps on the current umask as well (see ). The format of symbolic modes is: [ ugoa… ][ +-= ] perms [ ,… ] where perms is either zero or more letters from the set ‘rwxXst’, or a single letter from the set ‘ugo’. The following sections describe the operators and other details of symbolic modes. Setting Permissions The basic symbolic operations on a file's permissions are adding, removing, and setting the permission that certain users have to read, write, and execute or search the file. These operations have the following format: users operation permissions The spaces between the three parts above are shown for readability only; symbolic modes cannot contain spaces. The users part tells which users' access to the file is changed. It consists of one or more of the following letters (or it can be empty; see , for a description of what happens then). When more than one of these letters is given, the order that they are in does not matter. u owner of file, permissions forthe user who owns the file; g group, permissions forother users who are in the file's group; o other permissionsall other users; a all users; the same as ‘ugo’. The operation part tells how to change the affected users' access to the file, and is one of the following symbols: + adding permissionsto add the permissions to whatever permissions the usersalready have for the file; - removing permissions subtracting permissionsto remove the permissions from whatever permissions theusers already have for the file; = setting permissionsto make the permissions the only permissions that the usershave for the file. The permissions part tells what kind of access to the file should be changed; it is normally zero or more of the following letters. As with the users part, the order does not matter when more than one letter is given. Omitting the permissions part is useful only with the ‘=’ operation, where it gives the specified users no access at all to the file. r read permission, symbolicthe permission the users have to read the file; w write permission, symbolicthe permission the users have to write to the file; x execute/search permission, symbolicthe permission the users have to execute the file,or search it if it is a directory. For example, to give everyone permission to read and write a regular file, but not to execute it, use: a=rw To remove write permission for all users other than the file's owner, use: go-w The above command does not affect the access that the owner of the file has to it, nor does it affect whether other users can read or execute the file. To give everyone except a file's owner no permission to do anything with that file, use the mode below. Other users could still remove the file, if they have write permission on the directory it is in. go= Another way to specify the same thing is: og-rwx Copying Existing Permissions copying existing permissions permissions, copying existing You can base a file's permissions on its existing permissions. To do this, instead of using a series of ‘r’, ‘w’, or ‘x’ letters after the operator, you use the letter ‘u’, ‘g’, or ‘o’. For example, the mode o+g adds the permissions for users who are in a file's group to the permissions that other users have for the file. Thus, if the file started out as mode 664 (‘rw-rw-r--’), the above mode would change it to mode 666 (‘rw-rw-rw-’). If the file had started out as mode 741 (‘rwxr----x’), the above mode would change it to mode 745 (‘rwxr--r-x’). The ‘-’ and ‘=’ operations work analogously. Changing Special Mode Bits changing special mode bits In addition to changing a file's read, write, and execute/search permissions, you can change its special mode bits. See , for a summary of these special mode bits. To change the file mode bits to set the user ID on execution, use ‘u’ in the users part of the symbolic mode and ‘s’ in the permissions part. To change the file mode bits to set the group ID on execution, use ‘g’ in the users part of the symbolic mode and ‘s’ in the permissions part. To set both user and group ID on execution, omit the users part of the symbolic mode (or use ‘a’) and use ‘s’ in the permissions part. To change the file mode bits to set the restricted deletion flag or sticky bit, omit the users part of the symbolic mode (or use ‘a’) and use ‘t’ in the permissions part. For example, to set the set-user-ID mode bit of a program, you can use the mode: u+s To remove both set-user-ID and set-group-ID mode bits from it, you can use the mode: a-s To set the restricted deletion flag or sticky bit, you can use the mode: +t The combination ‘o+s’ has no effect. On GNU systems the combinations ‘u+t’ and ‘g+t’ have no effect, and ‘o+t’ acts like plain ‘+t’. The ‘=’ operator is not very useful with special mode bits. For example, the mode: o=t does set the restricted deletion flag or sticky bit, but it also removes all read, write, and execute/search permissions that users not in the file's group might have had for it. See , for additional rules concerning set-user-ID and set-group-ID bits and directories. Conditional Executability conditional executability There is one more special type of symbolic permission: if you use ‘X’ instead of ‘x’, execute/search permission is affected only if the file is a directory or already had execute permission. For example, this mode: a+X gives all users permission to search directories, or to execute files if anyone could execute them before. Making Multiple Changes multiple changes to permissions The format of symbolic modes is actually more complex than described above (see ). It provides two ways to make multiple changes to files' mode bits. The first way is to specify multiple operation and permissions parts after a users part in the symbolic mode. For example, the mode: og+rX-w gives users other than the owner of the file read permission and, if it is a directory or if someone already had execute permission to it, gives them execute/search permission; and it also denies them write permission to the file. It does not affect the permission that the owner of the file has for it. The above mode is equivalent to the two modes: og+rX og-w The second way to make multiple changes is to specify more than one simple symbolic mode, separated by commas. For example, the mode: a+r,go-w gives everyone permission to read the file and removes write permission on it for all users except its owner. Another example: u=rwx,g=rx,o= sets all of the permission bits for the file explicitly. (It gives users who are not in the file's group no permission at all for it.) The two methods can be combined. The mode: a+r,g+x-w gives all users permission to read the file, and gives users who are in the file's group permission to execute/search it as well, but not permission to write to it. The above mode could be written in several different ways; another is: u+r,g+rx,o+r,g-w The Umask and Protection umask and modes modes and umask If the users part of a symbolic mode is omitted, it defaults to ‘a’ (affect all users), except that any permissions that are set in the system variable umask are not affected. The value of umask can be set using the umask command. Its default value varies from system to system. giving away permissions Omitting the users part of a symbolic mode is generally not useful with operations other than ‘+’. It is useful with ‘+’ because it allows you to use umask as an easily customizable protection against giving away more permission to files than you intended to. As an example, if umask has the value 2, which removes write permission for users who are not in the file's group, then the mode: +w adds permission to write to the file to its owner and to other users who are in the file's group, but not to other users. In contrast, the mode: a+w ignores umask, and does give write permission for the file to all users. Numeric Modes numeric modes file mode bits, numeric octal numbers for file modes As an alternative to giving a symbolic mode, you can give an octal (base 8) number that represents the mode. This number is always interpreted in octal; you do not have to add a leading ‘0’, as you do in C. Mode ‘0055’ is the same as mode ‘55’. A numeric mode is usually shorter than the corresponding symbolic mode, but it is limited in that normally it cannot take into account the previous file mode bits; it can only set them absolutely. (As discussed in the next section, the set-user-ID and set-group-ID bits of directories are an exception to this general limitation.) The permissions granted to the user, to other users in the file's group, and to other users not in the file's group each require three bits, which are represented as one octal digit. The three special mode bits also require one bit each, and they are as a group represented as another octal digit. Here is how the bits are arranged, starting with the lowest valued bit: Value in Corresponding Mode Mode Bit Other users not in the file's group: 1 Execute/search 2 Write 4 Read Other users in the file's group: 10 Execute/search 20 Write 40 Read The file's owner: 100 Execute/search 200 Write 400 Read Special mode bits: 1000 Restricted deletion flag or sticky bit 2000 Set group ID on execution 4000 Set user ID on execution For example, numeric mode ‘4755’ corresponds to symbolic mode ‘u=rwxs,go=rx’, and numeric mode ‘664’ corresponds to symbolic mode ‘ug=rw,o=r’. Numeric mode ‘0’ corresponds to symbolic mode ‘a=’. Directories and the Set-User-ID and Set-Group-ID Bits On most systems, if a directory's set-group-ID bit is set, newly created subfiles inherit the same group as the directory, and newly created subdirectories inherit the set-group-ID bit of the parent directory. On a few systems, a directory's set-user-ID bit has a similar effect on the ownership of new subfiles and the set-user-ID bits of new subdirectories. These mechanisms let users share files more easily, by lessening the need to use chmod or chown to share new files. These convenience mechanisms rely on the set-user-ID and set-group-ID bits of directories. If commands like chmod and mkdir routinely cleared these bits on directories, the mechanisms would be less convenient and it would be harder to share files. Therefore, a command like chmod does not affect the set-user-ID or set-group-ID bits of a directory unless the user specifically mentions them in a symbolic mode, or sets them in a numeric mode. For example, on systems that support set-group-ID inheritance: # These commands leave the set-user-ID and # set-group-ID bits of the subdirectories alone, # so that they retain their default values. mkdir A B C chmod 755 A chmod 0755 B chmod u=rwx,go=rx C mkdir -m 755 D mkdir -m 0755 E mkdir -m u=rwx,go=rx F If you want to try to set these bits, you must mention them explicitly in the symbolic or numeric modes, e.g.: # These commands try to set the set-user-ID # and set-group-ID bits of the subdirectories. mkdir G H chmod 6755 G chmod u=rwx,go=rx,a+s H mkdir -m 6755 I mkdir -m u=rwx,go=rx,a+s J If you want to try to clear these bits, you must mention them explicitly in a symbolic mode, e.g.: # This command tries to clear the set-user-ID # and set-group-ID bits of the directory D. chmod a-s D This behavior is a GNU extension. Portable scripts should not rely on requests to set or clear these bits on directories, as POSIX allows implementations to ignore these requests. Date input formats date input formats get_date First, a quote: Our units of temporal measurement, from seconds on up to months, are so complicated, asymmetrical and disjunctive so as to make coherent mental reckoning in time all but impossible. Indeed, had some tyrannical god contrived to enslave our minds to time, to make it all but impossible for us to escape subjection to sodden routines and unpleasant surprises, he could hardly have done better than handing down our present system. It is like a set of trapezoidal building blocks, with no vertical or horizontal surfaces, like a language in which the simplest thought demands ornate constructions, useless particles and lengthy circumlocutions. Unlike the more successful patterns of language and science, which enable us to face experience boldly or at least level-headedly, our system of temporal calculation silently and persistently encourages our terror of time. … It is as though architects had to measure length in feet, width in meters and height in ells; as though basic instruction manuals demanded a knowledge of five different languages. It is no wonder then that we often look into our own immediate past or future, last Tuesday or a week from Sunday, with feelings of helpless confusion. … — Robert Grudin, Time and the Art of Living. This section describes the textual date representations that gnu programs accept. These are the strings you, as a user, can supply as arguments to the various programs. The C interface (via the get_date function) is not described here. General date syntax general date syntax items in date strings A date is a string, possibly empty, containing many items separated by whitespace. The whitespace may be omitted when no ambiguity arises. The empty string means the beginning of today (i.e., midnight). Order of the items is immaterial. A date string may contain many flavors of items: calendar date items time of day items time zone items day of the week items relative items pure numbers. We describe each of these item types in turn, below. numbers, written-out ordinal numbers first in date strings next in date strings last in date strings A few ordinal numbers may be written out in words in some contexts. This is most useful for specifying day of the week items or relative items (see below). Among the most commonly used ordinal numbers, the word ‘last’ stands for -1, ‘this’ stands for 0, and ‘first’ and ‘next’ both stand for 1. Because the word ‘second’ stands for the unit of time there is no way to write the ordinal number 2, but for convenience ‘third’ stands for 3, ‘fourth’ for 4, ‘fifth’ for 5, ‘sixth’ for 6, ‘seventh’ for 7, ‘eighth’ for 8, ‘ninth’ for 9, ‘tenth’ for 10, ‘eleventh’ for 11 and ‘twelfth’ for 12. months, written-out When a month is written this way, it is still considered to be written numerically, instead of being “spelled in full”; this changes the allowed strings. language, in dates In the current implementation, only English is supported for words and abbreviations like ‘AM’, ‘DST’, ‘EST’, ‘first’, ‘January’, ‘Sunday’, ‘tomorrow’, and ‘year’. language, in dates time zone item The output of the date command is not always acceptable as a date string, not only because of the language problem, but also because there is no standard meaning for time zone items like ‘IST’. When using date to generate a date string intended to be parsed later, specify a date format that is independent of language and that does not use time zone items other than ‘UTC’ and ‘Z’. Here are some ways to do this: $ LC_ALL=C TZ=UTC0 date Mon Mar 1 00:21:42 UTC 2004 $ TZ=UTC0 date +'%Y-%m-%d %H:%M:%SZ' 2004-03-01 00:21:42Z $ date --iso-8601=ns | tr T ' ' # --iso-8601 is a GNU extension. 2004-02-29 16:21:42,692722128-0800 $ date --rfc-2822 # a GNU extension Sun, 29 Feb 2004 16:21:42 -0800 $ date +'%Y-%m-%d %H:%M:%S %z' # %z is a GNU extension. 2004-02-29 16:21:42 -0800 $ date +'@%s.%N' # %s and %N are GNU extensions. @1078100502.692722128 case, ignored in dates comments, in dates Alphabetic case is completely ignored in dates. Comments may be introduced between round parentheses, as long as included parentheses are properly nested. Hyphens not followed by a digit are currently ignored. Leading zeros on numbers are ignored. Invalid dates like ‘2005-02-29’ or times like ‘24:00’ are rejected. In the typical case of a host that does not support leap seconds, a time like ‘23:59:60’ is rejected even if it corresponds to a valid leap second. Calendar date items calendar date item A calendar date item specifies a day of the year. It is specified differently, depending on whether the month is specified numerically or literally. All these strings specify the same calendar date: 1972-09-24 # iso 8601. 72-9-24 # Assume 19xx for 69 through 99, # 20xx for 00 through 68. 72-09-24 # Leading zeros are ignored. 9/24/72 # Common U.S. writing. 24 September 1972 24 Sept 72 # September has a special abbreviation. 24 Sep 72 # Three-letter abbreviations always allowed. Sep 24, 1972 24-sep-72 24sep72 The year can also be omitted. In this case, the last specified year is used, or the current year if none. For example: 9/24 sep 24 Here are the rules. iso 8601 date format date format, iso 8601 For numeric months, the iso 8601 format ‘year-month-day’ is allowed, where year is any positive number, month is a number between 01 and 12, and day is a number between 01 and 31. A leading zero must be present if a number is less than ten. If year is 68 or smaller, then 2000 is added to it; otherwise, if year is less than 100, then 1900 is added to it. The construct ‘month/day/year’, popular in the United States, is accepted. Also ‘month/day’, omitting the year. month names in date strings abbreviations for months Literal months may be spelled out in full: ‘January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’, ‘September’, ‘October’, ‘November’ or ‘December’. Literal months may be abbreviated to their first three letters, possibly followed by an abbreviating dot. It is also permitted to write ‘Sept’ instead of ‘September’. When months are written literally, the calendar date may be given as any of the following: day month year day month month day year day-month-year Or, omitting the year: month day Time of day items time of day item A time of day item in date strings specifies the time on a given day. Here are some examples, all of which represent the same time: 20:02:00.000000 20:02 8:02pm 20:02-0500 # In est (U.S. Eastern Standard Time). More generally, the time of day may be given as ‘hour:minute:second’, where hour is a number between 0 and 23, minute is a number between 0 and 59, and second is a number between 0 and 59 possibly followed by ‘.’ or ‘,’ and a fraction containing one or more digits. Alternatively, ‘:second’ can be omitted, in which case it is taken to be zero. On the rare hosts that support leap seconds, second may be 60. am in date strings pm in date strings midnight in date strings noon in date strings If the time is followed by ‘am’ or ‘pm’ (or ‘a.m.’ or ‘p.m.’), hour is restricted to run from 1 to 12, and ‘:minute’ may be omitted (taken to be zero). ‘am’ indicates the first half of the day, ‘pm’ indicates the second half of the day. In this notation, 12 is the predecessor of 1: midnight is ‘12am’ while noon is ‘12pm’. (This is the zero-oriented interpretation of ‘12am’ and ‘12pm’, as opposed to the old tradition derived from Latin which uses ‘12m’ for noon and ‘12pm’ for midnight.) time zone correction minutes, time zone correction by The time may alternatively be followed by a time zone correction, expressed as ‘shhmm’, where s is ‘+’ or ‘-’, hh is a number of zone hours and mm is a number of zone minutes. You can also separate hh from mm with a colon. When a time zone correction is given this way, it forces interpretation of the time relative to Coordinated Universal Time (utc), overriding any previous specification for the time zone or the local time zone. For example, ‘+0530’ and ‘+05:30’ both stand for the time zone 5.5 hours ahead of utc (e.g., India). The minute part of the time of day may not be elided when a time zone correction is used. This is the best way to specify a time zone correction by fractional parts of an hour. Either ‘am’/‘pm’ or a time zone correction may be specified, but not both. Time zone items time zone item A time zone item specifies an international time zone, indicated by a small set of letters, e.g., ‘UTC’ or ‘Z’ for Coordinated Universal Time. Any included periods are ignored. By following a non-daylight-saving time zone by the string ‘DST’ in a separate word (that is, separated by some white space), the corresponding daylight saving time zone may be specified. Alternatively, a non-daylight-saving time zone can be followed by a time zone correction, to add the two values. This is normally done only for ‘UTC’; for example, ‘UTC+05:30’ is equivalent to ‘+05:30’. Time zone items other than ‘UTC’ and ‘Z’ are obsolescent and are not recommended, because they are ambiguous; for example, ‘EST’ has a different meaning in Australia than in the United States. Instead, it's better to use unambiguous numeric time zone corrections like ‘-0500’, as described in the previous section. If neither a time zone item nor a time zone correction is supplied, time stamps are interpreted using the rules of the default time zone (see ). Day of week items day of week item The explicit mention of a day of the week will forward the date (only if necessary) to reach that day of the week in the future. Days of the week may be spelled out in full: ‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’ or ‘Saturday’. Days may be abbreviated to their first three letters, optionally followed by a period. The special abbreviations ‘Tues’ for ‘Tuesday’, ‘Wednes’ for ‘Wednesday’ and ‘Thur’ or ‘Thurs’ for ‘Thursday’ are also allowed. next day last day A number may precede a day of the week item to move forward supplementary weeks. It is best used in expression like ‘third monday’. In this context, ‘last day’ or ‘next day’ is also acceptable; they move one week before or after the day that day by itself would represent. A comma following a day of the week item is ignored. Relative items in date strings relative items in date strings displacement of dates Relative items adjust a date (or the current date if none) forward or backward. The effects of relative items accumulate. Here are some examples: 1 year 1 year ago 3 years 2 days year in date strings month in date strings fortnight in date strings week in date strings day in date strings hour in date strings minute in date strings The unit of time displacement may be selected by the string ‘year’ or ‘month’ for moving by whole years or months. These are fuzzy units, as years and months are not all of equal duration. More precise units are ‘fortnight’ which is worth 14 days, ‘week’ worth 7 days, ‘day’ worth 24 hours, ‘hour’ worth 60 minutes, ‘minute’ or ‘min’ worth 60 seconds, and ‘second’ or ‘sec’ worth one second. An ‘s’ suffix on these units is accepted and ignored. ago in date strings The unit of time may be preceded by a multiplier, given as an optionally signed number. Unsigned numbers are taken as positively signed. No number at all implies 1 for a multiplier. Following a relative item by the string ‘ago’ is equivalent to preceding the unit by a multiplier with value -1. day in date strings tomorrow in date strings yesterday in date strings The string ‘tomorrow’ is worth one day in the future (equivalent to ‘day’), the string ‘yesterday’ is worth one day in the past (equivalent to ‘day ago’). now in date strings today in date strings this in date strings The strings ‘now’ or ‘today’ are relative items corresponding to zero-valued time displacement, these strings come from the fact a zero-valued time displacement represents the current time when not otherwise changed by previous items. They may be used to stress other items, like in ‘12:00 today’. The string ‘this’ also has the meaning of a zero-valued time displacement, but is preferred in date strings like ‘this thursday’. When a relative item causes the resulting date to cross a boundary where the clocks were adjusted, typically for daylight saving time, the resulting date and time are adjusted accordingly. The fuzz in units can cause problems with relative items. For example, ‘2003-07-31 -1 month’ might evaluate to 2003-07-01, because 2003-06-31 is an invalid date. To determine the previous month more reliably, you can ask for the month before the 15th of the current month. For example: $ date -R Thu, 31 Jul 2003 13:02:39 -0700 $ date --date='-1 month' +'Last month was %B?' Last month was July? $ date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B!' Last month was June! Also, take care when manipulating dates around clock changes such as daylight saving leaps. In a few cases these have added or subtracted as much as 24 hours from the clock, so it is often wise to adopt universal time by setting the TZ environment variable to ‘UTC0’ before embarking on calendrical calculations. Pure numbers in date strings pure numbers in date strings The precise interpretation of a pure decimal number depends on the context in the date string. If the decimal number is of the form yyyymmdd and no other calendar date item (see ) appears before it in the date string, then yyyy is read as the year, mm as the month number and dd as the day of the month, for the specified calendar date. If the decimal number is of the form hhmm and no other time of day item appears before it in the date string, then hh is read as the hour of the day and mm as the minute of the hour, for the specified time of day. mm can also be omitted. If both a calendar date and a time of day appear to the left of a number in the date string, but no relative item, then the number overrides the year. Seconds since the Epoch If you precede a number with ‘@’, it represents an internal time stamp as a count of seconds. The number can contain an internal decimal point (either ‘.’ or ‘,’); any excess precision not supported by the internal representation is truncated toward minus infinity. Such a number cannot be combined with any other date item, as it specifies a complete time stamp. beginning of time, for POSIX epoch, for POSIX Internally, computer times are represented as a count of seconds since an epoch—a well-defined point of time. On GNU and POSIX systems, the epoch is 1970-01-01 00:00:00 utc, so ‘@0’ represents this time, ‘@1’ represents 1970-01-01 00:00:01 utc, and so forth. GNU and most other POSIX-compliant systems support such times as an extension to POSIX, using negative counts, so that ‘@-1’ represents 1969-12-31 23:59:59 utc. Traditional Unix systems count seconds with 32-bit two's-complement integers and can represent times from 1901-12-13 20:45:52 through 2038-01-19 03:14:07 utc. More modern systems use 64-bit counts of seconds with nanosecond subcounts, and can represent all the times in the known lifetime of the universe to a resolution of 1 nanosecond. On most hosts, these counts ignore the presence of leap seconds. For example, on most hosts ‘@915148799’ represents 1998-12-31 23:59:59 utc, ‘@915148800’ represents 1999-01-01 00:00:00 utc, and there is no way to represent the intervening leap second 1998-12-31 23:59:60 utc. Specifying time zone rules TZ Normally, dates are interpreted using the rules of the current time zone, which in turn are specified by the TZ environment variable, or by a system default if TZ is not set. To specify a different set of default time zone rules that apply just to one date, start the date with a string of the form ‘TZ="rule"’. The two quote characters (‘"’) must be present in the date, and any quotes or backslashes within rule must be escaped by a backslash. For example, with the GNU date command you can answer the question “What time is it in New York when a Paris clock shows 6:30am on October 31, 2004?” by using a date beginning with ‘TZ="Europe/Paris"’ as shown in the following shell transcript: $ export TZ="America/New_York" $ date --date='TZ="Europe/Paris" 2004-10-31 06:30' Sun Oct 31 01:30:00 EDT 2004 In this example, the operand begins with its own TZ setting, so the rest of that operand is processed according to ‘Europe/Paris’ rules, treating the string ‘2004-10-31 06:30’ as if it were in Paris. However, since the output of the date command is processed according to the overall time zone rules, it uses New York time. (Paris was normally six hours ahead of New York in 2004, but this example refers to a brief Halloween period when the gap was five hours.) A TZ value is a rule that typically names a location in the ‘tz’ database. A recent catalog of location names appears in the TWiki Date and Time Gateway. A few non-GNU hosts require a colon before a location name in a TZ setting, e.g., ‘TZ=":America/New_York"’. The ‘tz’ database includes a wide variety of locations ranging from ‘Arctic/Longyearbyen’ to ‘Antarctica/South_Pole’, but if you are at sea and have your own private time zone, or if you are using a non-GNU host that does not support the ‘tz’ database, you may need to use a POSIX rule instead. Simple POSIX rules like ‘UTC0’ specify a time zone without daylight saving time; other rules can specify simple daylight saving regimes. See See section ``Specifying the Time Zone with @code{TZ}'' in The GNU C Library. Authors of get_date authors of get_date Bellovin, Steven M. Salz, Rich Berets, Jim MacKenzie, David Meyering, Jim Eggert, Paul get_date was originally implemented by Steven M. Bellovin () while at the University of North Carolina at Chapel Hill. The code was later tweaked by a couple of people on Usenet, then completely overhauled by Rich $alz () and Jim Berets () in August, 1990. Various revisions for the gnu system were made by David MacKenzie, Jim Meyering, Paul Eggert and others. Pinard, F. Berry, K. This chapter was originally produced by François Pinard () from the getdate.y source code, and then edited by K. Berry (). Opening the Software Toolbox An earlier version of this chapter appeared in 2 (June 1994). It was written by Arnold Robbins. Toolbox Introduction This month's column is only peripherally related to the GNU Project, in that it describes a number of the GNU tools on your GNU/Linux system and how they might be used. What it's really about is the “Software Tools” philosophy of program development and usage. The software tools philosophy was an important and integral concept in the initial design and development of Unix (of which Linux and GNU are essentially clones). Unfortunately, in the modern day press of Internetworking and flashy GUIs, it seems to have fallen by the wayside. This is a shame, since it provides a powerful mental model for solving many kinds of problems. Many people carry a Swiss Army knife around in their pants pockets (or purse). A Swiss Army knife is a handy tool to have: it has several knife blades, a screwdriver, tweezers, toothpick, nail file, corkscrew, and perhaps a number of other things on it. For the everyday, small miscellaneous jobs where you need a simple, general purpose tool, it's just the thing. On the other hand, an experienced carpenter doesn't build a house using a Swiss Army knife. Instead, he has a toolbox chock full of specialized tools—a saw, a hammer, a screwdriver, a plane, and so on. And he knows exactly when and where to use each tool; you won't catch him hammering nails with the handle of his screwdriver. The Unix developers at Bell Labs were all professional programmers and trained computer scientists. They had found that while a one-size-fits-all program might appeal to a user because there's only one program to use, in practice such programs are difficult to write, difficult to maintain anddebug, and difficult to extend to meet new situations. Instead, they felt that programs should be specialized tools. In short, each program “should do one thing well.” No more and no less. Such programs are simpler to design, write, and get right—they only do one thing. Furthermore, they found that with the right machinery for hooking programs together, that the whole was greater than the sum of the parts. By combining several special purpose programs, you could accomplish a specific task that none of the programs was designed for, and accomplish it much more quickly and easily than if you had to write a special purpose program. We will see some (classic) examples of this further on in the column. (An important additional point was that, if necessary, take a detour and build any software tools you may need first, if you don't already have something appropriate in the toolbox.) I/O Redirection Hopefully, you are familiar with the basics of I/O redirection in the shell, in particular the concepts of “standard input,” “standard output,” and “standard error”. Briefly, “standard input” is a data source, where data comes from. A program should not need to either know or care if the data source is a disk file, a keyboard, a magnetic tape, or even a punched card reader. Similarly, “standard output” is a data sink, where data goes to. The program should neither know nor care where this might be. Programs that only read their standard input, do something to the data, and then send it on, are called filters, by analogy to filters in a water pipeline. With the Unix shell, it's very easy to set up data pipelines: program_to_create_data | filter1 | ... | filterN > final.pretty.data We start out by creating the raw data; each filter applies some successive transformation to the data, until by the time it comes out of the pipeline, it is in the desired form. This is fine and good for standard input and standard output. Where does the standard error come in to play? Well, think about filter1 in the pipeline above. What happens if it encounters an error in the data it sees? If it writes an error message to standard output, it will just disappear down the pipeline into filter2's input, and the user will probably never see it. So programs need a place where they can send error messages so that the user will notice them. This is standard error, and it is usually connected to your console or window, even if you have redirected standard output of your program away from your screen. For filter programs to work together, the format of the data has to be agreed upon. The most straightforward and easiest format to use is simply lines of text. Unix data files are generally just streams of bytes, with lines delimited by the ASCII lf (Line Feed) character, conventionally called a “newline” in the Unix literature. (This is '\n' if you're a C programmer.) This is the format used by all the traditional filtering programs. (Many earlier operating systems had elaborate facilities and special purpose programs for managing binary data. Unix has always shied away from such things, under the philosophy that it's easiest to simply be able to view and edit your data with a text editor.) OK, enough introduction. Let's take a look at some of the tools, and then we'll see how to hook them together in interesting ways. In the following discussion, we will only present those command line options that interest us. As you should always do, double check your system documentation for the full story. The who Command The first program is the who command. By itself, it generates a list of the users who are currently logged in. Although I'm writing this on a single-user system, we'll pretend that several people are logged in: $ who -| arnold console Jan 22 19:57 -| miriam ttyp0 Jan 23 14:19(:0.0) -| bill ttyp1 Jan 21 09:32(:0.0) -| arnold ttyp2 Jan 23 20:48(:0.0) Here, the ‘$’ is the usual shell prompt, at which I typed ‘who’. There are three people logged in, and I am logged in twice. On traditional Unix systems, user names are never more than eight characters long. This little bit of trivia will be useful later. The output of who is nice, but the data is not all that exciting. The cut Command The next program we'll look at is the cut command. This program cuts out columns or fields of input data. For example, we can tell it to print just the login name and full name from the /etc/passwd file. The /etc/passwd file has seven fields, separated by colons: arnold:xyzzy:2076:10:Arnold D. Robbins:/home/arnold:/bin/bash To get the first and fifth fields, we would use cut like this: $ cut -d: -f1,5 /etc/passwd -| root:Operator … -| arnold:Arnold D. Robbins -| miriam:Miriam A. Robbins … With the option, cut will cut out specific characters (i.e., columns) in the input lines. This is useful for input data that has fixed width fields, and does not have a field separator. For example, list the Monday dates for the current month: $ cal | cut -c 3-5 -|Mo -| -| 6 -| 13 -| 20 -| 27 The sort Command Next we'll look at the sort command. This is one of the most powerful commands on a Unix-style system; one that you will often find yourself using when setting up fancy data plumbing. The sort command reads and sorts each file named on the command line. It then merges the sorted data and writes it to standard output. It will read standard input if no files are given on the command line (thus making it into a filter). The sort is based on the character collating sequence or based on user-supplied ordering criteria. The uniq Command Finally (at least for now), we'll look at the uniq program. When sorting data, you will often end up with duplicate lines, lines that are identical. Usually, all you need is one instance of each line. This is where uniq comes in. The uniq program reads its standard input. It prints only one copy of each repeated line. It does have several options. Later on, we'll use the option, which prints each unique line, preceded by a count of the number of times that line occurred in the input. Putting the Tools Together Now, let's suppose this is a large ISP server system with dozens of users logged in. The management wants the system administrator to write a program that will generate a sorted list of logged in users. Furthermore, even if a user is logged in multiple times, his or her name should only show up in the output once. The administrator could sit down with the system documentation and write a C program that did this. It would take perhaps a couple of hundred lines of code and about two hours to write it, test it, and debug it. However, knowing the software toolbox, the administrator can instead start out by generating just a list of logged on users: $ who | cut -c1-8 -| arnold -| miriam -| bill -| arnold Next, sort the list: $ who | cut -c1-8 | sort -| arnold -| arnold -| bill -| miriam Finally, run the sorted list through uniq, to weed out duplicates: $ who | cut -c1-8 | sort | uniq -| arnold -| bill -| miriam The sort command actually has a option that does what uniq does. However, uniq has other uses for which one cannot substitute ‘sort -u’. The administrator puts this pipeline into a shell script, and makes it available for all the users on the system (‘#’ is the system administrator, or root, prompt): # cat > /usr/local/bin/listusers who | cut -c1-8 | sort | uniq ^D # chmod +x /usr/local/bin/listusers There are four major points to note here. First, with just four programs, on one command line, the administrator was able to save about two hours worth of work. Furthermore, the shell pipeline is just about as efficient as the C program would be, and it is much more efficient in terms of programmer time. People time is much more expensive than computer time, and in our modern “there's never enough time to do everything” society, saving two hours of programmer time is no mean feat. Second, it is also important to emphasize that with the combination of the tools, it is possible to do a special purpose job never imagined by the authors of the individual programs. Third, it is also valuable to build up your pipeline in stages, as we did here. This allows you to view the data at each stage in the pipeline, which helps you acquire the confidence that you are indeed using these tools correctly. Finally, by bundling the pipeline in a shell script, other users can use your command, without having to remember the fancy plumbing you set up for them. In terms of how you run them, shell scripts and compiled programs are indistinguishable. After the previous warm-up exercise, we'll look at two additional, more complicated pipelines. For them, we need to introduce two more tools. The first is the tr command, which stands for “transliterate.” The tr command works on a character-by-character basis, changing characters. Normally it is used for things like mapping upper case to lower case: $ echo ThIs ExAmPlE HaS MIXED case! | tr '[:upper:]' '[:lower:]' -| this example has mixed case! There are several options of interest: -c work on the complement of the listed characters, i.e.,operations apply to characters not in the given set -d delete characters in the first set from the output -s squeeze repeated characters in the output into just one character. We will be using all three options in a moment. The other command we'll look at is comm. The comm command takes two sorted input files as input data, and prints out the files' lines in three columns. The output columns are the data lines unique to the first file, the data lines unique to the second file, and the data lines that are common to both. The , , and command line options omit the respective columns. (This is non-intuitive and takes a little getting used to.) For example: $ cat f1 -| 11111 -| 22222 -| 33333 -| 44444 $ cat f2 -| 00000 -| 22222 -| 33333 -| 55555 $ comm f1 f2 -| 00000 -| 11111 -| 22222 -| 33333 -| 44444 -| 55555 The file name - tells comm to read standard input instead of a regular file. Now we're ready to build a fancy pipeline. The first application is a word frequency counter. This helps an author determine if he or she is over-using certain words. The first step is to change the case of all the letters in our input file to one case. “The” and “the” are the same word when doing counting. $ tr '[:upper:]' '[:lower:]' < whats.gnu | ... The next step is to get rid of punctuation. Quoted words and unquoted words should be treated identically; it's easiest to just get the punctuation out of the way. $ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \n' | ... The second tr command operates on the complement of the listed characters, which are all the letters, the digits, the underscore, and the blank. The ‘\n’ represents the newline character; it has to be left alone. (The ASCII tab character should also be included for good measure in a production script.) At this point, we have data consisting of words separated by blank space. The words only contain alphanumeric characters (and the underscore). The next step is break the data apart so that we have one word per line. This makes the counting operation much easier, as we will see shortly. $ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \n' | > tr -s ' ' '\n' | ... This command turns blanks into newlines. The option squeezes multiple newline characters in the output into just one. This helps us avoid blank lines. (The ‘>’ is the shell's “secondary prompt.” This is what the shell prints when it notices you haven't finished typing in all of a command.) We now have data consisting of one word per line, no punctuation, all one case. We're ready to count each word: $ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \n' | > tr -s ' ' '\n' | sort | uniq -c | ... At this point, the data might look something like this: 60 a 2 able 6 about 1 above 2 accomplish 1 acquire 1 actually 2 additional The output is sorted by word, not by count! What we want is the most frequently used words first. Fortunately, this is easy to accomplish, with the help of two more sort options: -n do a numeric sort, not a textual one -r reverse the order of the sort The final pipeline looks like this: $ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \n' | > tr -s ' ' '\n' | sort | uniq -c | sort -n -r -| 156 the -| 60 a -| 58 to -| 51 of -| 51 and … Whew! That's a lot to digest. Yet, the same principles apply. With six commands, on two lines (really one long one split for convenience), we've created a program that does something interesting and useful, in much less time than we could have written a C program to do the same thing. A minor modification to the above pipeline can give us a simple spelling checker! To determine if you've spelled a word correctly, all you have to do is look it up in a dictionary. If it is not there, then chances are that your spelling is incorrect. So, we need a dictionary. The conventional location for a dictionary is /usr/dict/words. On my GNU/Linux system,Redhat Linux 6.1, for the November 2000 revision of this article. this is a is a sorted, 45,402 word dictionary. Now, how to compare our file with the dictionary? As before, we generate a sorted list of words, one per line: $ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \n' | > tr -s ' ' '\n' | sort -u | ... Now, all we need is a list of words that are not in the dictionary. Here is where the comm command comes in. $ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \n' | > tr -s ' ' '\n' | sort -u | > comm -23 - /usr/dict/words The and options eliminate lines that are only in the dictionary (the second file), and lines that are in both files. Lines only in the first file (standard input, our stream of words), are words that are not in the dictionary. These are likely candidates for spelling errors. This pipeline was the first cut at a production spelling checker on Unix. There are some other tools that deserve brief mention. grep search files for text that matches a regular expression wc count lines, words, characters tee a T-fitting for data pipes, copies data to files and to standard output sed the stream editor, an advanced tool awk a data manipulation language, another advanced tool The software tools philosophy also espoused the following bit of advice: “Let someone else do the hard part.” This means, take something that gives you most of what you need, and then massage it the rest of the way until it's in the form that you want. To summarize: Each program should do one thing well. No more, no less. Combining programs with appropriate plumbing leads to results wherethe whole is greater than the sum of the parts. It also leads to noveluses of programs that the authors might never have imagined. Programs should never print extraneous header or trailer data, since thesecould get sent on down a pipeline. (A point we didn't mention earlier.) Let someone else do the hard part. Know your toolbox! Use each program appropriately. If you don't have anappropriate tool, build one. As of this writing, all the programs we've discussed are available via anonymous ftp from: ftp://gnudist.gnu.org/textutils/textutils-1.22.tar.gz. (There may be more recent versions available now.) None of what I have presented in this column is new. The Software Tools philosophy was first introduced in the book Software Tools, by Brian Kernighan and P.J. Plauger (Addison-Wesley, ISBN 0-201-03669-X). This book showed how to write and use software tools. It was written in 1976, using a preprocessor for FORTRAN named ratfor (RATional FORtran). At the time, C was not as ubiquitous as it is now; FORTRAN was. The last chapter presented a ratfor to FORTRAN processor, written in ratfor. ratfor looks an awful lot like C; if you know C, you won't have any problem following the code. In 1981, the book was updated and made available as Software Tools in Pascal (Addison-Wesley, ISBN 0-201-10342-7). Both books are still in print and are well worth reading if you're a programmer. They certainly made a major change in how I view programming. The programs in both books are available from Brian Kernighan's home page. For a number of years, there was an active Software Tools Users Group, whose members had ported the original ratfor programs to essentially every computer system with a FORTRAN compiler. The popularity of the group waned in the middle 1980s as Unix began to spread beyond universities. With the current proliferation of GNU code and other clones of Unix programs, these programs now receive little attention; modern C versions are much more efficient and do more than these programs do. Nevertheless, as exposition of good programming style, and evangelism for a still-valuable philosophy, these books are unparalleled, and I recommend them highly. Acknowledgment: I would like to express my gratitude to Brian Kernighan of Bell Labs, the original Software Toolsmith, for reviewing this column. Copying This Manual GNU Free Documentation License FDL, GNU Free Documentation License
Version 1.2, November 2002
Copyright © 2000,2001,2002 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. PREAMBLEThe purpose of this License is to make a manual, textbook, or otherfunctional and useful document free in the sense of freedom: toassure everyone the effective freedom to copy and redistribute it,with or without modifying it, either commercially or noncommercially.Secondarily, this License preserves for the author and publisher a wayto get credit for their work, while not being considered responsiblefor modifications made by others.This License is a kind of “copyleft”, which means that derivativeworks of the document must themselves be free in the same sense. Itcomplements the GNU General Public License, which is a copyleftlicense designed for free software.We have designed this License in order to use it for manuals for freesoftware, because free software needs free documentation: a freeprogram should come with manuals providing the same freedoms that thesoftware does. But this License is not limited to software manuals;it can be used for any textual work, regardless of subject matter orwhether it is published as a printed book. We recommend this Licenseprincipally for works whose purpose is instruction or reference. APPLICABILITY AND DEFINITIONSThis License applies to any manual or other work, in any medium, thatcontains a notice placed by the copyright holder saying it can bedistributed under the terms of this License. Such a notice grants aworld-wide, royalty-free license, unlimited in duration, to use thatwork under the conditions stated herein. The “Document”, below,refers to any such manual or work. Any member of the public is alicensee, and is addressed as “you”. You accept the license if youcopy, modify or distribute the work in a way requiring permissionunder copyright law.A “Modified Version” of the Document means any work containing theDocument or a portion of it, either copied verbatim, or withmodifications and/or translated into another language.A “Secondary Section” is a named appendix or a front-matter sectionof the Document that deals exclusively with the relationship of thepublishers or authors of the Document to the Document's overallsubject (or to related matters) and contains nothing that could falldirectly within that overall subject. (Thus, if the Document is inpart a textbook of mathematics, a Secondary Section may not explainany mathematics.) The relationship could be a matter of historicalconnection with the subject or with related matters, or of legal,commercial, philosophical, ethical or political position regardingthem.The “Invariant Sections” are certain Secondary Sections whose titlesare designated, as being those of Invariant Sections, in the noticethat says that the Document is released under this License. If asection does not fit the above definition of Secondary then it is notallowed to be designated as Invariant. The Document may contain zeroInvariant Sections. If the Document does not identify any InvariantSections then there are none.The “Cover Texts” are certain short passages of text that are listed,as Front-Cover Texts or Back-Cover Texts, in the notice that says thatthe Document is released under this License. A Front-Cover Text maybe at most 5 words, and a Back-Cover Text may be at most 25 words.A “Transparent” copy of the Document means a machine-readable copy,represented in a format whose specification is available to thegeneral public, that is suitable for revising the documentstraightforwardly with generic text editors or (for images composed ofpixels) generic paint programs or (for drawings) some widely availabledrawing editor, and that is suitable for input to text formatters orfor automatic translation to a variety of formats suitable for inputto text formatters. A copy made in an otherwise Transparent fileformat whose markup, or absence of markup, has been arranged to thwartor discourage subsequent modification by readers is not Transparent.An image format is not Transparent if used for any substantial amountof text. A copy that is not “Transparent” is called “Opaque”.Examples of suitable formats for Transparent copies include plainascii without markup, Texinfo input format, La&tex; inputformat, SGML or XML using a publicly availableDTD, and standard-conforming simple HTML,PostScript or PDF designed for human modification. Examplesof transparent image formats include PNG, XCF andJPG. Opaque formats include proprietary formats that can beread and edited only by proprietary word processors, SGML orXML for which the DTD and/or processing tools arenot generally available, and the machine-generated HTML,PostScript or PDF produced by some word processors foroutput purposes only.The “Title Page” means, for a printed book, the title page itself,plus such following pages as are needed to hold, legibly, the materialthis License requires to appear in the title page. For works informats which do not have any title page as such, “Title Page” meansthe text near the most prominent appearance of the work's title,preceding the beginning of the body of the text.A section “Entitled XYZ” means a named subunit of the Document whosetitle either is precisely XYZ or contains XYZ in parentheses followingtext that translates XYZ in another language. (Here XYZ stands for aspecific section name mentioned below, such as “Acknowledgements”,“Dedications”, “Endorsements”, or “History”.) To “Preserve the Title”of such a section when you modify the Document means that it remains asection “Entitled XYZ” according to this definition.The Document may include Warranty Disclaimers next to the notice whichstates that this License applies to the Document. These WarrantyDisclaimers are considered to be included by reference in thisLicense, but only as regards disclaiming warranties: any otherimplication that these Warranty Disclaimers may have is void and hasno effect on the meaning of this License. VERBATIM COPYINGYou may copy and distribute the Document in any medium, eithercommercially or noncommercially, provided that this License, thecopyright notices, and the license notice saying this License appliesto the Document are reproduced in all copies, and that you add no otherconditions whatsoever to those of this License. You may not usetechnical measures to obstruct or control the reading or furthercopying of the copies you make or distribute. However, you may acceptcompensation in exchange for copies. If you distribute a large enoughnumber of copies you must also follow the conditions in section 3.You may also lend copies, under the same conditions stated above, andyou may publicly display copies. COPYING IN QUANTITYIf you publish printed copies (or copies in media that commonly haveprinted covers) of the Document, numbering more than 100, and theDocument's license notice requires Cover Texts, you must enclose thecopies in covers that carry, clearly and legibly, all these CoverTexts: Front-Cover Texts on the front cover, and Back-Cover Texts onthe back cover. Both covers must also clearly and legibly identifyyou as the publisher of these copies. The front cover must presentthe full title with all words of the title equally prominent andvisible. You may add other material on the covers in addition.Copying with changes limited to the covers, as long as they preservethe title of the Document and satisfy these conditions, can be treatedas verbatim copying in other respects.If the required texts for either cover are too voluminous to fitlegibly, you should put the first ones listed (as many as fitreasonably) on the actual cover, and continue the rest onto adjacentpages.If you publish or distribute Opaque copies of the Document numberingmore than 100, you must either include a machine-readable Transparentcopy along with each Opaque copy, or state in or with each Opaque copya computer-network location from which the general network-usingpublic has access to download using public-standard network protocolsa complete Transparent copy of the Document, free of added material.If you use the latter option, you must take reasonably prudent steps,when you begin distribution of Opaque copies in quantity, to ensurethat this Transparent copy will remain thus accessible at the statedlocation until at least one year after the last time you distribute anOpaque copy (directly or through your agents or retailers) of thatedition to the public.It is requested, but not required, that you contact the authors of theDocument well before redistributing any large number of copies, to givethem a chance to provide you with an updated version of the Document. MODIFICATIONSYou may copy and distribute a Modified Version of the Document underthe conditions of sections 2 and 3 above, provided that you releasethe Modified Version under precisely this License, with the ModifiedVersion filling the role of the Document, thus licensing distributionand modification of the Modified Version to whoever possesses a copyof it. In addition, you must do these things in the Modified Version: Use in the Title Page (and on the covers, if any) a title distinctfrom that of the Document, and from those of previous versions(which should, if there were any, be listed in the History sectionof the Document). You may use the same title as a previous versionif the original publisher of that version gives permission. List on the Title Page, as authors, one or more persons or entitiesresponsible for authorship of the modifications in the ModifiedVersion, together with at least five of the principal authors of theDocument (all of its principal authors, if it has fewer than five),unless they release you from this requirement. State on the Title page the name of the publisher of theModified Version, as the publisher. Preserve all the copyright notices of the Document. Add an appropriate copyright notice for your modificationsadjacent to the other copyright notices. Include, immediately after the copyright notices, a license noticegiving the public permission to use the Modified Version under theterms of this License, in the form shown in the Addendum below. Preserve in that license notice the full lists of Invariant Sectionsand required Cover Texts given in the Document's license notice. Include an unaltered copy of this License. Preserve the section Entitled “History”, Preserve its Title, and addto it an item stating at least the title, year, new authors, andpublisher of the Modified Version as given on the Title Page. Ifthere is no section Entitled “History” in the Document, create onestating the title, year, authors, and publisher of the Document asgiven on its Title Page, then add an item describing the ModifiedVersion as stated in the previous sentence. Preserve the network location, if any, given in the Document forpublic access to a Transparent copy of the Document, and likewisethe network locations given in the Document for previous versionsit was based on. These may be placed in the “History” section.You may omit a network location for a work that was published atleast four years before the Document itself, or if the originalpublisher of the version it refers to gives permission. For any section Entitled “Acknowledgements” or “Dedications”, Preservethe Title of the section, and preserve in the section all thesubstance and tone of each of the contributor acknowledgements and/ordedications given therein. Preserve all the Invariant Sections of the Document,unaltered in their text and in their titles. Section numbersor the equivalent are not considered part of the section titles. Delete any section Entitled “Endorsements”. Such a sectionmay not be included in the Modified Version. Do not retitle any existing section to be Entitled “Endorsements” orto conflict in title with any Invariant Section. Preserve any Warranty Disclaimers. If the Modified Version includes new front-matter sections orappendices that qualify as Secondary Sections and contain no materialcopied from the Document, you may at your option designate some or allof these sections as invariant. To do this, add their titles to thelist of Invariant Sections in the Modified Version's license notice.These titles must be distinct from any other section titles.You may add a section Entitled “Endorsements”, provided it containsnothing but endorsements of your Modified Version by variousparties—for example, statements of peer review or that the text hasbeen approved by an organization as the authoritative definition of astandard.You may add a passage of up to five words as a Front-Cover Text, and apassage of up to 25 words as a Back-Cover Text, to the end of the listof Cover Texts in the Modified Version. Only one passage ofFront-Cover Text and one of Back-Cover Text may be added by (orthrough arrangements made by) any one entity. If the Document alreadyincludes a cover text for the same cover, previously added by you orby arrangement made by the same entity you are acting on behalf of,you may not add another; but you may replace the old one, on explicitpermission from the previous publisher that added the old one.The author(s) and publisher(s) of the Document do not by this Licensegive permission to use their names for publicity for or to assert orimply endorsement of any Modified Version. COMBINING DOCUMENTSYou may combine the Document with other documents released under thisLicense, under the terms defined in section 4 above for modifiedversions, provided that you include in the combination all of theInvariant Sections of all of the original documents, unmodified, andlist them all as Invariant Sections of your combined work in itslicense notice, and that you preserve all their Warranty Disclaimers.The combined work need only contain one copy of this License, andmultiple identical Invariant Sections may be replaced with a singlecopy. If there are multiple Invariant Sections with the same name butdifferent contents, make the title of each such section unique byadding at the end of it, in parentheses, the name of the originalauthor or publisher of that section if known, or else a unique number.Make the same adjustment to the section titles in the list ofInvariant Sections in the license notice of the combined work.In the combination, you must combine any sections Entitled “History”in the various original documents, forming one section Entitled“History”; likewise combine any sections Entitled “Acknowledgements”,and any sections Entitled “Dedications”. You must delete allsections Entitled “Endorsements.” COLLECTIONS OF DOCUMENTSYou may make a collection consisting of the Document and other documentsreleased under this License, and replace the individual copies of thisLicense in the various documents with a single copy that is included inthe collection, provided that you follow the rules of this License forverbatim copying of each of the documents in all other respects.You may extract a single document from such a collection, and distributeit individually under this License, provided you insert a copy of thisLicense into the extracted document, and follow this License in allother respects regarding verbatim copying of that document. AGGREGATION WITH INDEPENDENT WORKSA compilation of the Document or its derivatives with other separateand independent documents or works, in or on a volume of a storage ordistribution medium, is called an “aggregate” if the copyrightresulting from the compilation is not used to limit the legal rightsof the compilation's users beyond what the individual works permit.When the Document is included in an aggregate, this License does notapply to the other works in the aggregate which are not themselvesderivative works of the Document.If the Cover Text requirement of section 3 is applicable to thesecopies of the Document, then if the Document is less than one half ofthe entire aggregate, the Document's Cover Texts may be placed oncovers that bracket the Document within the aggregate, or theelectronic equivalent of covers if the Document is in electronic form.Otherwise they must appear on printed covers that bracket the wholeaggregate. TRANSLATIONTranslation is considered a kind of modification, so you maydistribute translations of the Document under the terms of section 4.Replacing Invariant Sections with translations requires specialpermission from their copyright holders, but you may includetranslations of some or all Invariant Sections in addition to theoriginal versions of these Invariant Sections. You may include atranslation of this License, and all the license notices in theDocument, and any Warranty Disclaimers, provided that you also includethe original English version of this License and the original versionsof those notices and disclaimers. In case of a disagreement betweenthe translation and the original version of this License or a noticeor disclaimer, the original version will prevail.If a section in the Document is Entitled “Acknowledgements”,“Dedications”, or “History”, the requirement (section 4) to Preserveits Title (section 1) will typically require changing the actualtitle. TERMINATIONYou may not copy, modify, sublicense, or distribute the Document exceptas expressly provided for under this License. Any other attempt tocopy, modify, sublicense or distribute the Document is void, and willautomatically terminate your rights under this License. However,parties who have received copies, or rights, from you under thisLicense will not have their licenses terminated so long as suchparties remain in full compliance. FUTURE REVISIONS OF THIS LICENSEThe Free Software Foundation may publish new, revised versionsof the GNU Free Documentation License from time to time. Such newversions will be similar in spirit to the present version, but maydiffer in detail to address new problems or concerns. Seehttp://www.gnu.org/copyleft/.Each version of the License is given a distinguishing version number.If the Document specifies that a particular numbered version of thisLicense “or any later version” applies to it, you have the option offollowing the terms and conditions either of that specified version orof any later version that has been published (not as a draft) by theFree Software Foundation. If the Document does not specify a versionnumber of this License, you may choose any version ever published (notas a draft) by the Free Software Foundation. ADDENDUM: How to use this License for your documents To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page: Copyright (C) year your name. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''. If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with...Texts.” line with this: with the Invariant Sections being list their titles, with the Front-Cover Texts being list, and with the Back-Cover Texts being list. If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.
xreflabel="Index" id="Index"> Index !, see !=, see %, see %b, see &, see -’, removing files beginning with, see *, see +, see +, see +page_range, see -, see -, see -, see - and Unix rm, see –, see –across, see –address-radix, see –adjustment, see –all, see –all, see –all, see –all, see –all, see –all, see –all, see –all-repeated, see –almost-all, see –apparent-size, see –append, see –archive, see –author, see –backup, see –backup, see –backup, see –backup, see –backup, see –before, see –binary, see –block-size, see –block-size, see –block-size, see –block-size=size, see –body-numbering, see –boot, see –bourne-shell, see –buffer-size, see –bytes, see –bytes, see –bytes, see –bytes, see –bytes, see –bytes, see –bytes, see –c-shell, see –canonicalize, see –canonicalize-existing, see –canonicalize-missing, see –changes, see –changes, see –changes, see –characters, see –chars, see –check, see –check-chars, see –classify, see –color, see –columns, see –command, see –complement, see –count, see –count, see –count-links, see –crown-margin, see –csh, see –date, see –date, see –dead, see –decode, see –delimiter, see –delimiters, see –dereference, see –dereference, see –dereference, see –dereference, see –dereference, see –dereference, see –dereference-args, see –dereference-command-line, see –dereference-command-line-symlink-to-dir, see –dictionary-order, see –digits, see –directory, see –directory, see –directory, see –dired, see –double-space, see –echo, see –elide-empty-files, see –escape, see –exact, see –exclude-from=FILE, see –exclude-type, see –exclude=PATTERN, see –expand-tabs, see –fast, see –field-separator, see –fields, see –file, see –file, see –file-system, see –file-type, see –files0-from=FILE, see –files0-from=FILE, see –first-line-number, see –follow, see –footer-numbering, see –force, see –force, see –force, see –force, see –force, see –form-feed, see –format, see –format, see –format, see –format=format, see –format=format, see –from, see –full-time, see –general-numeric-sort, see –group, see –group, see –group-directories-first, see –groups, see –hardware-platform, see –head-lines, see –header, see –header-numbering, see –heading, see –help, see –hide-control-chars, see –hide=pattern, see –human-readable, see –human-readable, see –human-readable, see –human-readable, see –ignore-backups, see –ignore-case, see –ignore-case, see –ignore-case, see –ignore-environment, see –ignore-fail-on-non-empty, see –ignore-garbage, see –ignore-interrupts, see –ignore-leading-blanks, see –ignore-nonprinting, see –ignore=pattern, see –indent, see –indicator-style, see –initial, see –inode, see –inodes, see –input-range, see –interactive, see –interactive, see –interactive, see –interactive, see –iterations=NUMBER, see –join-blank-lines, see –join-lines, see –keep-files, see –kernel-name, see –kernel-release, see –kernel-version, see –key, see –length, see –line-bytes, see –lines, see –lines, see –lines, see –lines, see –link, see –literal, see –local, see –login, see –login, see –lookup, see –machine, see –max-depth=DEPTH, see –max-line-length, see –max-unchanged-stats, see –merge, see –merge, see –mesg, see –message, see –mode, see –mode, see –mode, see –mode, see –month-sort, see –name, see –no-create, see –no-dereference, see –no-dereference, see –no-dereference, see –no-dereference, see –no-dereference, see –no-file-warnings, see –no-group, see –no-newline, see –no-preserve-root, see –no-preserve-root, see –no-preserve-root, see –no-preserve-root, see –no-renumber, see –no-sync, see –no-target-directory, see –no-target-directory, see –no-target-directory, see –no-target-directory, see –no-target-directory, see –nodename, see –null, see –number, see –number-format, see –number-lines, see –number-nonblank, see –number-separator, see –number-width, see –numeric-sort, see –numeric-suffixes, see –numeric-uid-gid, see –omit-header, see –omit-pagination, see –one-file-system, see –one-file-system, see –one-file-system, see –only-delimited, see –operating-system, see –output, see –output, see –output-delimiter, see –output-duplicates, see –output-tabs, see –owner, see –page-increment, see –page_width, see –pages=page_range, see –parents, see –parents, see –parents, see –pid, see –portability, see –portability, see –prefix, see –preserve, see –preserve-environment, see –preserve-root, see –preserve-root, see –preserve-root, see –preserve-root, see –preserve-timestamps, see –print-database, see –print-type, see –printf=format, see –processor, see –quiet, see –quiet, see –quiet, see –quiet, see –quiet, see –quiet, see –quiet, see –quiet, see –quote-name, see –quoting-style, see –random-sort, see –random-source, see –random-source, see –random-source, see –read-bytes, see –real, see –recursive, see –recursive, see –recursive, see –recursive, see –recursive, see –recursive, see –reference, see –reference, see –reference, see –reference, see –reference, see –regex, see –remove, see –remove-destination, see –repeated, see –reply, see –reply, see –retry, see –reverse, see –reverse, see –rfc-2822, see –rfc-3339=timespec, see –rfc-822, see –save, see –section-delimiter, see –sep-string, see –separate-dirs, see –separator, see –separator, see –serial, see –set, see –sh, see –shell, see –show-all, see –show-control-chars, see –show-control-chars, see –show-ends, see –show-nonprinting, see –show-nonprinting, see –show-tabs, see –si, see –si, see –si, see –si, see –silent, see –silent, see –silent, see –silent, see –silent, see –silent, see –silent, see –silent, see –size, see –size=BYTES, see –skip-bytes, see –skip-chars, see –skip-fields, see –sleep-interval, see –sort, see –spaces, see –sparse=when, see –split-only, see –squeeze-blank, see –stable, see –starting-line-number, see –status, see –strings, see –strip, see –strip-trailing-slashes, see –strip-trailing-slashes, see –suffix, see –suffix, see –suffix, see –suffix, see –suffix, see –suffix, see –suffix-length, see –summarize, see –symbolic, see –symbolic-link, see –sync, see –sysv, see –tabs, see –tabs, see –tabsize, see –tagged-paragraph, see –target-directory, see –target-directory, see –target-directory, see –target-directory, see –target-directory, see –temporary-directory, see –terse, see –text, see –time, see –time, see –time, see –time-style, see –time-style, see –total, see –traditional, see –type, see –uniform-spacing, see –unique, see –unique, see –universal, see –unset, see –update, see –update, see –user, see –utc, see –verbose, see –verbose, see –verbose, see –verbose, see –verbose, see –verbose, see –verbose, see –verbose, see –verbose, see –verbose, see –verbose, see –verbose, see –verbose, see –verbose, see –verbose, see –version, see –warn, see –width, see –width, see –width, see –width, see –width, see –words, see –wrap, see –writable, see –zero, see –zero-terminated, see –zero-terminated, see -0, see -1, see -1, see -1, see -2, see -2, see -3, see -a, see -a, see -a, see -a, see -a, see -a, see -a, see -a, see -a, see -A, see -a, see -a, see -a, see -a, see -a, see -a, see -A, see -A, see -b, see -b, see -B, see -b, see -B, see -b, see -b, see -b, see -b, see -b, see -b, see -B, see -b, see -b, see -b, see -b, see -b, see -b, see -b, see -b, see -b, see -b, see -b, see -c, see -c, see -c, see -c, see -c, see -c, see -c, see -c, see -c, see -c, see -C, see -c, see -c, see -c, see -c, see -c, see -c, see -C, see -c, see -c, see -c, see -c, see -c, see -column, see -d, see -d, see -d, see -D, see -d, see -d, see -d, see -d, see -D, see -d, see -d, see -d, see -D, see -d, see -d, see -d, see -d, see -d, see -d, see -d, see -e, see -E, see -e, see -e, see -e, see -e, see -E, see -e, see -ef, see -eq, see -f, see -f, see -F, see -f, see -f, see -f, see -f, see -f, see -f, see -f, see -f, see -F, see -f, see -f, see -f, see -f, see -F, see -f, see -f, see -f, see -f, see -f, see -F, see -f, see -f, see -F, see -f, see -f, see -f format, see -G, see -g, see -g, see -G, see -g, see -g, see -G, see -g, see -g, see -ge, see -gt, see -H, see -h, see -H, see -h, see -H, see -h, see -H, see -h, see -H, see -h, see -H, see -h, see -H, see -h, see -h, see -H, see -h, see -i, see -i, see -i, see -i, see -i, see -I, see -i, see -i, see -i, see -i, see -I, see -i, see -i, see -i, see -i, see -i, see -i, see -i, see -i, see -i, see -J, see -j, see -k, see -k, see -k, see -k, see -k, see -k, see -k, see -l, see -l, see -L, see -L, see -L, see -l, see -l, see -L, see -L, see -L, see -l, see -l, see -L, see -L, see -l, see -l, see -l, see -l, see -l, see -L, see -le, see -lt, see -m, see -m, see -m, see -m, see -m, see -m, see -m, see -m, see -m, see -m, see -m, see -M, see -m, see -m, see -m, see -n, see -n, see -n, see -n, see -n, see -n, see -n, see -N, see -n, see -n, see -n, see -n, see -n, see -n, see -n, see -N, see -n, see -N, see -n, see -n, see -n NUMBER, see -ne, see -nt, see -o, see -o, see -O, see -o, see -o, see -o, see -o, see -o, see -o, see -ot, see -p, see -p, see -P, see -p, see -p, see -P, see -P, see -P, see -P, see -p, see -p, see -p, see -p, see -P, see -p, see -p, see -p, see -P, see -q, see -q, see -Q, see -q, see -q, see -q, see -q, see -r, see -R, see -r, see -r, see -r, see -r, see -R, see -R, see -R, see -R, see -r, see -r, see -R, see -r, see -R, see -R, see -r, see -r, see -r, see -r, see -s, see -s, see -s, see -s, see -s, see -s, see -S, see -S, see -s, see -s, see -S, see -s, see -S, see -S, see -s, see -S, see -s, see -S, see -s, see -s, see -s, see -s, see -S, see -s, see -s, see -s, see -s, see -S, see -s, see -s, see -s, see -S, see -s, see -s, see -s, see -S, see -s BYTES, see , see -T, see -t, see -t, see -T, see -t, see -T, see -t, see -T, see -t, see -T, see -t, see -T, see -t, see -T, see -t, see -t, see -t, see -T, see -t, see -t, see -T, see -t, see -t, see -t, see -T, see -t, see -u, see -u, see -u, see -u, see -u, see -u, see -u, see -u, see -U, see -u, see -u, see -u, see -u, see -u, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -v, see -w, see -w, see -w, see -w, see -w, see -w, see -w, see -W, see -w, see -w, see -w, see -w, see -w, see -width, see -x, see -x, see -x, see -x, see -x, see -x, see -X, see -x, see -X FILE, see -z, see -z, see -z, see -z, see -z, see .cshrc, see /, see /bin/sh, see /etc/passwd, see /etc/shells, see 128-bit checksum, see 16-bit checksum, see 160-bit checksum, see 224-bit checksum, see 256-bit checksum, see 384-bit checksum, see 4.2 file system type, see 512-bit checksum, see <, see <=, see =, see =, see ==, see >, see >=, see \( regexp operator, see \+ regexp operator, see \? regexp operator, see \c, see \ooo, see \uhhhh, see \Uhhhhhhhh, see \xhh, see \| regexp operator, see _POSIX2_VERSION, see _POSIX2_VERSION, see _POSIX2_VERSION, see _POSIX2_VERSION, see _POSIX2_VERSION, see A abbreviations for months, see access permission tests, see access permissions, changing, see access time, see access time, changing, see access time, printing or sorting files by, see access time, show the most recent, see across columns, see across, listing files, see adding permissions, see addition, see ago in date strings, see all repeated lines, outputting, see alnum, see alpha, see alternate ebcdic, converting to, see always color option, see always interactive option, see am i, see am in date strings, see and operator, see and operator, see append, see appending to the output file, see appropriate privileges, see appropriate privileges, see appropriate privileges, see appropriate privileges, see arbitrary date strings, parsing, see arbitrary text, displaying, see arithmetic tests, see ASCII dump of files, see ascii, converting to, see atime, changing, see atime, printing or sorting files by, see atime, show the most recent, see attributes, file, see authors of get_date, see auto color option, see automounter file systems, see B b for block special file, see background jobs, stopping at terminal write, see backslash escapes, see backslash escapes, see backslash sequences for file names, see backup files, ignoring, see backup options, see backup suffix, see backups, making, see backups, making, see backups, making, see backups, making, see backups, making, see backups, making only, see base64, see Base64 decoding, see base64 encoding, see basename, see baud rate, setting, see beeping at input buffer full, see beginning of time, see beginning of time, for POSIX, see Bellovin, Steven M., see Berets, Jim, see Berry, K., see Berry, K., see binary, see binary I/O, see binary input files, see blank, see blank lines, numbering, see blanks, ignoring leading, see block (space-padding), see block size, see block size, see block size of conversion, see block size of input, see block size of output, see block special check, see block special files, see block special files, creating, see BLOCK_SIZE, see BLOCKSIZE, see body, numbering, see Bourne shell syntax for color setup, see breaks, cause interrupts, see breaks, ignoring, see brkint, see bs, see BSD sum, see BSD tail, see BSD touch compatibility, see bsn, see bugs, reporting, see built-in shell commands, conflicts with, see built-in shell commands, conflicts with, see built-in shell commands, conflicts with, see byte count, see byte-swapping, see C c for character special file, see C shell syntax for color setup, see C-s/C-q flow control, see calendar date item, see case folding, see case translation, see case, ignored in dates, see cat, see cbreak, see cbs, see CD-ROM file system type, see cdfs file system type, see change or print terminal settings, see changed files, verbosely describing, see changed owners, verbosely describing, see changing access permissions, see changing file attributes, see changing file ownership, see changing file timestamps, see changing group ownership, see changing group ownership, see changing special mode bits, see character classes, see character count, see character size, see character special check, see character special files, see character special files, creating, see characters, special, see check file types, see checking for sortedness, see checksum, 128-bit, see checksum, 16-bit, see checksum, 160-bit, see checksum, 224-bit, see checksum, 256-bit, see checksum, 384-bit, see checksum, 512-bit, see chgrp, see chmod, see chown, see chroot, see cksum, see clocal, see cntrl, see color database, printing, see color setup, see color, distinguishing file types with, see cols, see column to wrap data after, see COLUMNS, see columns, see COLUMNS, see combination settings, see comm, see command-line operands to shuffle, see commands for controlling processes, see commands for delaying, see commands for exit status, see commands for file name manipulation, see commands for invoking other commands, see commands for printing text, see commands for printing the working context, see commands for printing user information, see commands for redirection, see commands for system context, see commas, outputting between files, see comments, in dates, see common field, joining on, see common lines, see common options, see compare values, see comparing sorted files, see comparison operators, see concatenate and write files, see conditional executability, see conditions, see conflicts with shell built-ins, see conflicts with shell built-ins, see conflicts with shell built-ins, see connectives, logical, see connectives, logical, see context splitting, see context, system, see control characters, using ‘^c’, see control settings, see controlling terminal, see conv, see conversion block size, see conversion specifiers, date, see conversion specifiers, literal, see conversion specifiers, time, see converting tabs to spaces, see converting while copying a file, see cooked, see Coordinated Universal Time, see copying directories recursively, see copying existing permissions, see copying files, see copying files and directories, see copying files and setting attributes, see core utilities, see count, see cp, see crashes and corruption, see CRC checksum, see cread, see creating directories, see creating FIFOs (named pipes), see creating links (hard only), see creating links (hard or soft), see creating output file, avoiding, see creating output file, requiring, see crn, see crown margin, see crt, see crterase, see crtkill, see crtscts, see csh syntax for color setup, see csn, see csplit, see cstopb, see ctime, printing or sorting by, see ctime, show the most recent, see ctlecho, see current working directory, printing, see cut, see cyclic redundancy check, see D data, erasing, see database for color setup, printing, see date, see date conversion specifiers, see date format, iso 8601, see date input formats, see date options, see date strings, parsing, see day in date strings, see day of week item, see dd, see dec, see decctlq, see Decode base64 data, see delay for a specified time, see delaying commands, see deleting characters, see dereferencing symbolic links, see descriptor follow option, see destination directory, see destination directory, see destination directory, see destination directory, see destination directory, see destinations, multiple output, see device file, disk, see df, see DF_BLOCK_SIZE, see dictionary order, see differing lines, see digit, see dir, see dircolors, see direct, see direct I/O, see directories, copying, see directories, copying recursively, see directories, creating, see directories, creating with given attributes, see directories, removing (recursively), see directories, removing empty, see directory, see directory check, see directory components, printing, see directory deletion, ignoring failures, see directory deletion, reporting, see directory I/O, see directory listing, see directory listing, brief, see directory listing, recursive, see directory listing, verbose, see directory order, listing by, see directory, stripping from file names, see dired Emacs mode support, see dirname, see disabling special characters, see disambiguating group names and IDs, see disk allocation, see disk device file, see disk usage, see disk usage by file system, see disk usage for files, see diskette file system, see displacement of dates, see displaying text, see displaying value of a symbolic link, see division, see do nothing, successfully, see do nothing, unsuccessfully, see DOS file system, see double spacing, see down columns, see dsusp, see dsync, see du, see DU_BLOCK_SIZE, see E ebcdic, converting to, see echo, see echo, see echoctl, see echoe, see echok, see echoke, see echonl, see echoprt, see effective user and group IDs, printing, see effective user ID, printing, see efs file system type, see Eggert, Paul, see eight-bit characters, see eight-bit characters, see eight-bit input, see ek, see empty files, creating, see empty lines, numbering, see entire files, output of, see env, see environment variables, printing, see environment, preserving, see environment, printing, see environment, running a program in a modified, see eof, see eol, see eol2, see epoch, for POSIX, see epoch, seconds since, see equal string check, see equivalence classes, see erase, see erasing data, see error messages, omitting, see error messages, omitting, see error messages, omitting, see evaluation of expressions, see even parity, see evenp, see exabyte, definition of, see examples of date, see examples of expr, see exbibyte, definition of, see excl, see excluding files from du, see executable file check, see executables and file type, marking, see execute/search permission, see execute/search permission, symbolic, see existence-of-file check, see existing backup method, see exit status commands, see exit status of chroot, see exit status of env, see exit status of expr, see exit status of false, see exit status of ls, see exit status of nice, see exit status of nohup, see exit status of pathchk, see exit status of printenv, see exit status of sort, see exit status of su, see exit status of test, see exit status of true, see exit status of tty, see expand, see expr, see expression evaluation, see expression evaluation, see expressions, numeric, see expressions, string, see extension, sorting files by, see F factor, see failure exit status, see false, see fascism, see fdatasync, see FDL, GNU Free Documentation License, see ffn, see field separator character, see fields, padding numeric, see FIFOs, creating, see file attributes, changing, see file characteristic tests, see file contents, dumping unambiguously, see file information, preserving, see file mode bits, numeric, see file name manipulation, see file name pattern expansion, disabled, see file names, checking validity and portability, see file names, stripping directory and suffix, see file offset radix, see file ownership, changing, see file sizes, see file space usage, see file status, see file system disk usage, see file system sizes, see file system space, retrieving current data more slowly, see file system space, retrieving old data more quickly, see file system status, see file system types, limiting output to certain, see file system types, printing, see file systems, see file systems and hard links, see file systems, omitting copying to different, see file timestamps, changing, see file type and executables, marking, see file type tests, see file type, marking, see file types, see file types, special, see file utilities, see files beginning with ‘-’, removing, see files, copying, see fingerprint, 128-bit, see fingerprint, 160-bit, see fingerprint, 224-bit, see fingerprint, 256-bit, see fingerprint, 384-bit, see fingerprint, 512-bit, see first in date strings, see first part of files, outputting, see fixed-length records, converting to variable-length, see flow control, hardware, see flow control, software, see flushing, disabling, see fmt, see fold, see folding long input lines, see footers, numbering, see force deletion, see formatting file contents, see formatting of numbers in seq, see formatting times, see formatting times, see fortnight in date strings, see fsync, see G general date syntax, see general numeric sort, see get_date, see gibibyte, definition of, see gigabyte, definition of, see giving away permissions, see globbing, disabled, see GMT, see grand total of disk space, see graph, see Greenwich Mean Time, see group IDs, disambiguating, see group names, disambiguating, see group owner, default, see group ownership of installed files, setting, see group ownership, changing, see group ownership, changing, see group wheel, not supported, see group, permissions for, see groups, see growing files, see H hangups, immunity to, see hard link check, see hard link, defined, see hard links, see hard links to directories, see hard links, counting in du, see hard links, creating, see hard links, creating, see hard links, preserving, see hardware class, see hardware flow control, see hardware platform, see hardware type, see hat notation for control characters, see head, see head of output, see headers, numbering, see help, online, see hex dump of files, see High Sierra file system, see holes, copying files with, see HOME, see horizontal, listing files, see host processor type, see hostid, see hostname, see hostname, see hour in date strings, see hsfs file system type, see human-readable output, see human-readable output, see human-readable output, see human-readable output, see hup[cl], see hurd, author, printing, see I ibs, see icanon, see icrnl, see id, see idle time, see iexten, see if, see iflag, see ignbrk, see igncr, see ignore file systems, see Ignore garbage in base64 stream, see ignoring case, see ignpar, see imaxbel, see immunity to hangups, see implementation, hardware, see including files from du, see including files from du, see indenting lines, see index, see information, about current users, see initial part of files, outputting, see initial tabs, converting, see inlcr, see inode number, printing, see inode usage, see inode, and hard links, see inodes, written buffered, see inpck, see input block size, see input encoding, UTF-8, see input range to shuffle, see input settings, see input tabs, see install, see interactivity, see interactivity, see intr, see invocation of commands, modified, see isig, see iso 8601 date format, see ISO/IEC 10646, see ispeed, see istrip, see items in date strings, see iterations, selecting the number of, see iuclc, see iutf8, see ixany, see ixoff, see ixon, see J join, see K kernel name, see kernel release, see kernel version, see kibibyte, definition of, see kibibytes for file sizes, see kibibytes for file system sizes, see kill, see kill, see kilobyte, definition of, see Knuth, Donald E., see L language, in dates, see last day, see last day, see last in date strings, see last modified dates, displaying in du, see last part of files, outputting, see LC_ALL, see LC_ALL, see LC_COLLATE, see LC_COLLATE, see LC_COLLATE, see LC_COLLATE, see LC_COLLATE, see LC_CTYPE, see LC_CTYPE, see LC_MESSAGES, see LC_NUMERIC, see LC_NUMERIC, see LC_NUMERIC, see LC_TIME, see LC_TIME, see LC_TIME, see LC_TIME, see LC_TIME, see LCASE, see lcase, see lcase, converting to, see lchown, see lchown, see leading directories, creating missing, see leading directory components, stripping, see left margin, see length, see limiting output of du, see line, see line count, see line numbering, see line settings of terminal, see line-breaking, see line-by-line comparison, see LINES, see link, see links, creating, see links, creating, see Linux file system types, see literal conversion specifiers, see litout, see ln, see ln format for nl, see lnext, see local file system types, see local settings, see logging out and continuing to run, see logical and operator, see logical and operator, see logical connectives, see logical connectives, see logical or operator, see logical or operator, see logical pages, numbering on, see login name, printing, see login sessions, printing users with, see login shell, see login shell, creating, see login time, see LOGNAME, see logname, see long ls format, see lower, see lowercase, translating to output, see ls, see LS_BLOCK_SIZE, see LS_COLORS, see M machine type, see machine-readable stty output, see MacKenzie, D., see MacKenzie, David, see Makefiles, installing programs in, see manipulating files, see manipulation of file names, see match, see matching patterns, see MD5, see md5sum, see mebibyte, definition of, see mebibytes for file sizes, see megabyte, definition of, see merging files, see merging files in parallel, see merging sorted files, see message status, see message-digest, 128-bit, see message-digest, 160-bit, see message-digest, 224-bit, see message-digest, 256-bit, see message-digest, 384-bit, see message-digest, 512-bit, see Meyering, J., see Meyering, Jim, see midnight in date strings, see min, see minute in date strings, see minutes, time zone correction by, see MIT AI lab, see mkdir, see mkfifo, see mknod, see modem control, see modes and umask, see modes of created directories, setting, see modes of created FIFOs, setting, see modification time, sorting files by, see modified command invocation, see modified environment, running a program in a, see modify time, changing, see month in date strings, see month names in date strings, see months, sorting by, see months, written-out, see MS-DOS file system, see mtime, changing, see multicolumn output, generating, see multiple changes to permissions, see multiplication, see multipliers after numbers, see mv, see N name follow option, see name of kernel, see named pipe check, see named pipes, creating, see network node name, see never interactive option, see newer files, copying only, see newer files, moving only, see newer-than file check, see newline echoing after kill, see newline, echoing, see newline, translating to crlf, see newline, translating to return, see next day, see next day, see next in date strings, see NFS file system type, see NFS mounts from BSD to HP-UX, see NFS mounts from BSD to HP-UX, see nice, see niceness, see nl, see nl, see nln, see no-op, see noatime, see nocreat, see noctty, see node name, see noerror, see noflsh, see nofollow, see nohup, see nohup.out, see nolinks, see non-directories, copying as special files, see non-directory suffix, stripping, see nonblock, see nonblocking I/O, see none backup method, see none color option, see none, sorting option for ls, see nonempty file check, see nonprinting characters, ignoring, see nonzero-length string check, see noon in date strings, see not-equal string check, see notrunc, see now in date strings, see numbered backup method, see numbering lines, see numbers, written-out, see numeric expressions, see numeric field padding, see numeric modes, see numeric operations, see numeric sequences, see numeric sort, see numeric tests, see numeric uid and gid, see numeric user and group IDs, see O obs, see ocrnl, see octal dump of files, see octal numbers for file modes, see od, see odd parity, see oddp, see of, see ofdel, see ofill, see oflag, see olcuc, see older-than file check, see once interactive option, see one file system, restricting du to, see one file system, restricting rm to, see one-line output format, see onlcr, see onlret, see onocr, see operating on characters, see operating on sorted files, see operating system name, see opost, see option delimiter, see options for date, see or operator, see or operator, see ordinal numbers, see ospeed, see other permissions, see output block size, see output file name prefix, see output file name prefix, see output file name suffix, see output format, see output format, portable, see output null-byte-terminated lines, see output of entire files, see output of parts of files, see output settings, see output tabs, see overwriting of input, allowed, see overwriting of input, allowed, see owned by effective group ID check, see owned by effective user ID check, see owner of file, permissions for, see owner, default, see ownership of installed files, setting, see P p for FIFO file, see pad character, see pad instead of timing for delaying, see padding of numeric fields, see paragraphs, reformatting, see parenb, see parent directories and cp, see parent directories, creating, see parent directories, creating missing, see parent directories, removing, see parentheses for grouping, see parity, see parity errors, marking, see parity, ignoring, see parmrk, see parodd, see parsing date strings, see parts of files, output of, see pass8, see passwd entry, and su shell, see paste, see Paterson, R., see PATH, see PATH, see pathchk, see pattern matching, see PC file system, see pcfs, see pebibyte, definition of, see permission tests, see permissions of installed files, setting, see permissions, changing access, see permissions, copying existing, see permissions, for changing file timestamps, see permissions, output by ls, see petabyte, definition of, see phone directory order, see pieces, splitting a file into, see Pinard, F., see Pinard, F., see pipe fitting, see Plass, Michael F., see platform, hardware, see pm in date strings, see portable file names, checking for, see portable output format, see POSIX, see POSIX output format, see POSIXLY_CORRECT, see POSIXLY_CORRECT, see POSIXLY_CORRECT, see POSIXLY_CORRECT, see POSIXLY_CORRECT, see POSIXLY_CORRECT, see POSIXLY_CORRECT, see POSIXLY_CORRECT, see POSIXLY_CORRECT, and block size, see pr, see prime factors, see print, see print name of current directory, see print system information, see print terminal file name, see printenv, see printf, see printing all or some environment variables, see printing color database, see printing current user information, see printing current usernames, see printing groups a user is in, see printing real and effective user and group IDs, see printing text, see printing text, commands for, see printing the current time, see printing the effective user ID, see printing the host identifier, see printing the hostname, see printing user's login name, see printing, preparing files for, see processes, commands for controlling, see prompting, and ln, see prompting, and mv, see prompting, and rm, see prompts, forcing, see prompts, omitting, see prterase, see ptx, see punct, see pure numbers in date strings, see pwd, see Q quit, see quoting style, see R radix for file offsets, see random sort, see random source for shredding, see random source for shuffling, see random source for sorting, see random sources, see ranges, see raw, see read errors, ignoring, see read from stdin and write to stdout and files, see read permission, see read permission, symbolic, see read system call, and holes, see readable file check, see readlink, see real user and group IDs, printing, see recursive directory listing, see recursively changing access permissions, see recursively changing file ownership, see recursively changing group ownership, see recursively copying directories, see redirection, see reformatting paragraph text, see regular expression matching, see regular file check, see relations, numeric or string, see relative items in date strings, see release of kernel, see remainder, see remote hostname, see removing empty directories, see removing files after shredding, see removing files or directories, see removing files or directories (via the unlink syscall), see removing permissions, see repeated characters, see repeated lines, outputting, see repeated output of a string, see restricted deletion flag, see restricted shell, see return, ignoring, see return, translating to newline, see return, translating to newline, see reverse sorting, see reverse sorting, see reversing files, see rm, see rmdir, see rn format for nl, see root as default owner, see root directory, allow recursive destruction, see root directory, allow recursive modification, see root directory, allow recursive modification, see root directory, allow recursive modification, see root directory, disallow recursive destruction, see root directory, disallow recursive modification, see root directory, disallow recursive modification, see root directory, disallow recursive modification, see root directory, running a program in a specified, see root, becoming, see rows, see rprnt, see RTS/CTS flow control, see running a program in a modified environment, see running a program in a specified root directory, see rz format for nl, see S Salz, Rich, see same file check, see sane, see scheduling, affecting, see screen columns, see seconds since the epoch, see section delimiters of pages, see seek, see self-backups, see send a signal to processes, see sentences and line-breaking, see separator for numbers in seq, see seq, see sequence of numbers, see set-group-ID, see set-group-ID check, see set-user-ID, see set-user-ID check, see setgid, see setting permissions, see setting the hostname, see setting the time, see setuid, see setup for color, see sh syntax for color setup, see SHA-1, see SHA-2, see sha1sum, see sha224sum, see sha256sum, see sha384sum, see sha512sum, see SHELL, see SHELL environment variable, and color, see shell utilities, see shred, see shuf, see shuffling files, see SI output, see SI output, see SI output, see SI output, see simple backup method, see SIMPLE_BACKUP_SUFFIX, see single-column output of files, see size, see size for main memory sorting, see size of file to shred, see size of files, reporting, see size of files, sorting files by, see skip, see sleep, see socket check, see software flow control, see sort, see sort field, see sort stability, see sort zero-terminated lines, see sort zero-terminated lines, see sort's last-resort comparison, see sorted files, operations on, see sorting files, see sorting ls output, see space, see sparse files, copying, see special characters, see special file types, see special files, see special settings, see specifying sets of characters, see speed, see split, see splitting a file into pieces, see splitting a file into pieces by context, see squeezing blank lines, see squeezing repeat characters, see Stallman, R., see standard input, see standard output, see start, see stat, see status time, printing or sorting by, see status time, show the most recent, see sticky, see sticky bit check, see stop, see stop bits, see strftime and date, see string constants, outputting, see string expressions, see string tests, see strip directory and suffix from file names, see stripping non-directory suffix, see stripping symbol table information, see stripping trailing slashes, see stripping trailing slashes, see stty, see su, see substitute user and group IDs, see substr, see subtracting permissions, see subtraction, see successful exit, see suffix, stripping from file names, see sum, see summarizing files, see super-user, becoming, see superblock, writing, see supplementary groups, printing, see susp, see swab (byte-swapping), see swap space, saving text image in, see swtch, see symbol table information, stripping, see symbolic (soft) links, creating, see symbolic link check, see symbolic link to directory, controlling traversal of, see symbolic link to directory, never traverse, see symbolic link to directory, never traverse, see symbolic link to directory, never traverse, see symbolic link to directory, traverse each that is encountered, see symbolic link to directory, traverse each that is encountered, see symbolic link to directory, traverse each that is encountered, see symbolic link to directory, traverse each that is specified on the command line, see symbolic link to directory, traverse each that is specified on the command line, see symbolic link to directory, traverse each that is specified on the command line, see symbolic link, defined, see symbolic links and pwd, see symbolic links, changing group, see symbolic links, changing owner, see symbolic links, changing owner, see symbolic links, copying, see symbolic links, copying with, see symbolic links, dereferencing, see symbolic links, dereferencing in du, see symbolic links, dereferencing in stat, see symbolic links, following, see symbolic links, permissions of, see symbolic modes, see sync, see sync, see sync (padding with nulls), see synchronize disk and memory, see synchronized data and metadata I/O, see synchronized data and metadata writes, before finishing, see synchronized data reads, see synchronized data writes, before finishing, see syslog, see system context, see system information, printing, see system name, printing, see System V sum, see T tab stops, setting, see tabn, see tabs, see tabs to spaces, converting, see tac, see tagged paragraphs, see tail, see tandem, see target directory, see target directory, see target directory, see target directory, see target directory, see tebibyte, definition of, see tee, see telephone directory order, see temporary directory, see terabyte, definition of, see TERM, see terminal check, see terminal file name, printing, see terminal lines, currently used, see terminal settings, see terminal, using color iff, see terse output, see test, see text, see text I/O, see text image, saving in swap space, see text input files, see text utilities, see text, displaying, see text, reformatting, see this in date strings, see time, see time, see time conversion specifiers, see time formats, see time formats, see time of day item, see time setting, see time style, see time style, see time units, see time zone correction, see time zone item, see time zone item, see time, printing or setting, see TIME_STYLE, see TIME_STYLE, see timestamps of installed files, preserving, see timestamps, changing file, see TMPDIR, see today in date strings, see tomorrow, see tomorrow in date strings, see topological sort, see tostop, see total counts, see touch, see tr, see trailing slashes, see translating characters, see true, see truncating output file, avoiding, see tsort, see tty, see Twenex, see two-way parity, see type size, see TZ, see TZ, see TZ, see TZ, see TZ, see TZ, see TZ, see TZ, see U u, and disabling special characters, see ucase, converting to, see ufs file system type, see umask and modes, see uname, see unblock, see unexpand, see Unicode, see uniq, see unique lines, outputting, see uniquify files, see uniquifying output, see unlink, see unprintable characters, ignoring, see unsorted directory listing, see upper, see uppercase, translating to lowercase, see use time, changing, see use time, printing or sorting files by, see use time, show the most recent, see USER, see user ID, switching, see user IDs, disambiguating, see user information, commands for, see user name, printing, see user names, disambiguating, see usernames, printing current, see users, see UTC, see utmp, see utmp, see utmp, see V valid file names, checking for, see variable-length records, converting to fixed-length, see vdir, see verbose ls format, see verifying MD5 checksums, see version number, finding, see version of kernel, see version, sorting option for ls, see version-control Emacs variable, see VERSION_CONTROL, see VERSION_CONTROL, see VERSION_CONTROL, see VERSION_CONTROL, see VERSION_CONTROL, see vertical sorted files in columns, see vtn, see W wc, see week in date strings, see werase, see wheel group, not supported, see who, see who am i, see whoami, see word count, see working context, see working directory, printing, see wrap data, see wrapping long input lines, see writable file check, see write permission, see write permission, symbolic, see write, allowed, see wtmp, see wtmp, see X xcase, see xdigit, see XON/XOFF flow control, see Y year in date strings, see yes, see yesterday, see yesterday in date strings, see yottabyte, definition of, see Youmans, B., see Z zero-length string check, see zettabyte, definition of, see |, see