| [Top] | [Contents] | [Index] | [ ? ] |
This manual documents version 4.1 of the GNU file utilities.
1. Introduction Caveats, overview, and authors. 2. Common options 3. File permissions Access modes. 4. Date input formats Specifying date strings. 5. Directory listing ls dir vdir d v dircolors 6. Basic operations cp dd install mv rm shred 7. Special file types ln mkdir rmdir mkfifo mknod 8. Changing file attributes chgrp chmod chown touch 9. Disk usage df du sync Index General index.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This manual is incomplete: No attempt is made to explain basic file 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.
The GNU file utilities are mostly compatible with the POSIX.2 standard.
Please report bugs to bug-fileutils@gnu.org. 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 section `Bugs' in GNU CC.
This manual was originally derived from the Unix man pages in the distribution, 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. François Pinard did the initial conversion to Texinfo format. Karl Berry did the indexing, some reorganization, and editing of the results. Richard Stallman contributed his usual invaluable insights to the overall process.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Certain options are available in all of these programs (in fact, every GNU program should accept them). Rather than writing identical descriptions for each of the programs, they are described here.
2.1 Backup options -b -S -V, in some programs. 2.2 Block size BLOCK_SIZE and --block-size, in some programs. 2.3 Target directory --target-directory, in some programs. 2.4 Trailing slashes --strip-trailing-slashes, in some programs.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
VERSION_CONTROL
environment variable is used. And if VERSION_CONTROL is not set,
the default backup type is `existing'.
Note that the short form of this option, `-b' does not accept any argument. Using `-b' is equivalent to using `--backup=existing'.
This 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):
SIMPLE_BACKUP_SUFFIX
environment variable is used. And if SIMPLE_BACKUP_SUFFIX is not
set, the default is `~', just as in Emacs.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Some GNU programs (at least df, du, and ls) display
file sizes in "blocks". You can adjust the block size to make file
sizes easier to read. The block size used for display is independent of
any filesystem block size.
Normally, disk usage sizes are rounded up, disk free space sizes are rounded down, and other sizes are rounded to the nearest value with ties rounding to an even value.
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
df command.
Similarly, DU_BLOCK_SIZE specifies the default for du and
LS_BLOCK_SIZE for ls.
BLOCK_SIZE
POSIXLY_CORRECT
command_BLOCK_SIZE nor the BLOCK_SIZE
variables are set, but this variable is set, the block size defaults to 512.
If none of the above environment variables are set, the block size currently defaults to 1024 bytes, but this number may change in the future.
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.
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; `M' stands
for 1,000,000 bytes. (SI, the International System of Units, defines
these power-of-1000 prefixes.)
An integer block size can be followed by a size letter to specify a
multiple of that size. When this notation is used, the size letters
normally stand for powers of 1024, and can be followed by an optional
`B' for "byte"; but if followed by `D' (for "decimal
byte"), they stand for powers of 1000. For example,
BLOCK_SIZE=4MB is equivalent to BLOCK_SIZE=4194304, and
BLOCK_SIZE=4MD is equivalent to BLOCK_SIZE=4000000.
The following size letters are defined. Large sizes like 1Y
may be rejected by your computer due to limitations of its arithmetic.
human-readable,
or 10^3 = 1000 for si.
Block size defaults can be overridden by an explicit
`--block-size=size' option. The `-k' or
`--kilobytes' option is equivalent to `--block-size=1k', which
is the default unless the POSIXLY_CORRECT environment variable is
set. The `-h' or `--human-readable' option is equivalent to
`--block-size=human-readable'. The `--si' option
is equivalent to `--block-size=si'.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Some GNU programs (at least cp, install, ln, and
mv) allow you to specify the target directory via this option:
The interface for most programs is that after processing options and a
finite (possibly zero) number of fixed-position arguments, the remaining
argument list is either expected to be empty, or is a list of items
(usually files) that will all be handled identically. The xargs
program is designed to work well with this convention.
The commands in the mv-family are unusual in that they take
a variable number of arguments with a special case at the end
(namely, the target directory). This makes it nontrivial to perform some
operations, e.g., "move all files from here to ../d/", because
mv * ../d/ might exhaust the argument space, and ls | xargs ...
doesn't have a clean way to specify an extra final argument for each
invocation of the subject command. (It can be done by going through a
shell command, but that requires more human labor and brain power than
it should.)
The --target-directory option allows the cp,
install, ln, and mv programs to be used conveniently
with xargs. For example, you can move the files from the
current directory to a sibling directory, d like this:
(However, this doesn't move files whose names begin with `.'.)
ls |xargs mv --target-directory=../d |
If you use the GNU find program, you can move all
files with this command:
find . -mindepth 1 -maxdepth 1 \ | xargs mv --target-directory=../d |
But that will fail if there are no files in the current directory
or if any file has a name containing a newline character.
The following example removes those limitations and requires both
GNU find and GNU xargs:
find . -mindepth 1 -maxdepth 1 -print0 \
| xargs --null --no-run-if-empty \
mv --target-directory=../d
|
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.2 and is consistent with
other parts of that standard.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Each file has a set of permissions that control the kinds of access that users have to that file. The permissions for a file are also called its access mode. They can be represented either in symbolic form or as an octal number.
3.1 Structure of File Permissions Structure of file permissions. 3.2 Symbolic Modes Mnemonic permissions representation. 3.3 Numeric Modes Permissions as octal numbers.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There are three kinds of permissions that a user can have for a file:
There are three categories of users who may have different permissions to perform any of the above operations on a file:
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
filesystem 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, a file's permissions have three special components, which affect only executable files (programs) and, on some systems, directories:
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Symbolic modes represent changes to files' permissions as
operations on single-character symbols. They allow you to modify either
all or selected parts of files' permissions, optionally based on
their previous values, and perhaps on the current umask as well
(see section 3.2.6 The Umask and Protection).
The format of symbolic modes is:
[ugoa...][[+-=][rwxXstugo...]...][,...] |
The following sections describe the operators and other details of symbolic modes.
3.2.1 Setting Permissions Basic operations on permissions. 3.2.2 Copying Existing Permissions Copying existing permissions. 3.2.3 Changing Special Permissions Special permissions. 3.2.4 Conditional Executability Conditionally affecting executability. 3.2.5 Making Multiple Changes Making multiple changes. 3.2.6 The Umask and Protection The effect of the umask.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 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 section 3.2.6 The Umask and Protection, 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
g
o
a
The operation part tells how to change the affected users' access to the file, and is one of the following symbols:
+
-
=
The permissions part tells what kind of access to the file should be changed; it is 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
w
x
For example, to give everyone permission to read and write a file, but not to execute it, use:
a=rw |
To remove write permission for from 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-rxw |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
You can base a file's permissions on its existing permissions. To do this, instead of using `r', `w', or `x' after the operator, you use the letter `u', `g', or `o'. For example, the mode
o+g |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In addition to changing a file's read, write, and execute permissions, you can change its special permissions. See section 3.1 Structure of File Permissions, for a summary of these permissions.
To change a file's permission 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 a file's permission to set the group ID on execution, use `g' in the users part of the symbolic mode and `s' in the permissions part.
To change a file's permission to stay permanently on the swap device, use `o' in the users part of the symbolic mode and `t' in the permissions part.
For example, to add set user ID permission to a program, you can use the mode:
u+s |
To remove both set user ID and set group ID permission from it, you can use the mode:
ug-s |
To cause a program to be saved on the swap device, you can use the mode:
o+t |
Remember that the special permissions only affect files that are executable, plus, on some systems, directories (on which they have different meanings; see section 3.1 Structure of File Permissions). Also, the combinations `u+t', `g+t', and `o+s' have no effect.
The `=' operator is not very useful with special permissions; for example, the mode:
o=t |
does cause the file to be saved on the swap device, but it also removes all read, write, and execute permissions that users not in the file's group might have had for it.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There is one more special type of symbolic permission: if you use `X' instead of `x', execute permission is affected only if the file already had execute permission or is a directory. It affects directories' execute permission even if they did not initially have any execute permissions set.
For example, this mode:
a+X |
gives all users permission to execute files (or search directories) if anyone could before.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The format of symbolic modes is actually more complex than described above (see section 3.2.1 Setting Permissions). It provides two ways to make multiple changes to files' permissions.
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 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 non-special permissions 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 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 |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
File permissions are stored internally as integers. As an alternative to giving a symbolic mode, you can give an octal (base 8) number that corresponds to the internal representation of the new 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 it cannot take into account a file's previous permissions; it can only set them absolutely.
On most systems, the permissions granted to the user, to other users in the file's group, and to other users not in the file's group are each stored as three bits, which are represented as one octal digit. The three special permissions are also each stored as one bit, 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 Permission
Other users not in the file's group:
1 Execute
2 Write
4 Read
Other users in the file's group:
10 Execute
20 Write
40 Read
The file's owner:
100 Execute
200 Write
400 Read
Special permissions:
1000 Save text image on swap device
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 `ugo='.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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
getdate function) is not described here.
Although the date syntax here can represent any possible time since the
year zero, computer integers often cannot represent such a wide range of
time. On POSIX systems, the clock starts at 1970-01-01 00:00:00
UTC: POSIX does not require support for times before the
POSIX Epoch and times far in the future. Traditional Unix systems
have 32-bit signed time_t and can represent times from 1901-12-13
20:45:52 through 2038-01-19 03:14:07 UTC. Systems with 64-bit
signed time_t can represent all the times in the known
lifetime of the universe.
4.1 General date syntax Common rules. 4.2 Calendar date items 19 Dec 1994. 4.3 Time of day items 9:20pm. 4.4 Time zone items EST, PDT, GMT, ... 4.5 Day of week items Monday and others. 4.6 Relative items in date strings next tuesday, 2 years ago. 4.7 Pure numbers in date strings 19931219, 1440. 4.8 Authors of getdateBellovin, Eggert, Salz, Berets, et al.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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:
We describe each of these item types in turn, below.
A few numbers may be written out in words in most contexts. This is most useful for specifying day of the week items or relative items (see below). Here is the list: `first' for 1, `next' for 2, `third' 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. Also, `last' means exactly -1.
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.
In the current implementation, only English is supported for words and abbreviations like `AM', `DST', `EST', `first', `January', `Sunday', `tomorrow', and `year'.
The output of date 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 Fri Dec 15 19:48:05 UTC 2000 $ TZ=UTC0 date +"%Y-%m-%d %H:%M:%SZ" 2000-12-15 19:48:05Z $ date --iso-8601=seconds # a GNU extension 2000-12-15T11:48:05-0800 $ date --rfc-822 # a GNU extension Fri, 15 Dec 2000 11:48:05 -0800 $ date +"%Y-%m-%d %H:%M:%S %z" # %z is a GNU extension. 2000-12-15 11:48:05 -0800 |
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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
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.
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 |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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:0 20:02 8:02pm 20:02-0500 # In EST (U.S. Eastern Standard Time). |
More generally, the time of the 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. Alternatively, `:second' can be omitted, in which case it is taken to be zero.
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.)
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. 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. The minute part of the time of the 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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 |
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.
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.
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').
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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 section 4.2 Calendar date items) 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 the 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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
getdate
getdate was originally implemented by Steven M. Bellovin
(smb@research.att.com) 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 (rsalz@bbn.com)
and Jim Berets (jberets@bbn.com) in August, 1990. Various
revisions for the GNU system were made by David MacKenzie, Jim Meyering,
Paul Eggert and others.
This chapter was originally produced by François Pinard (pinard@iro.umontreal.ca) from the `getdate.y' source code, and then edited by K. Berry (kb@cs.umb.edu).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes the ls command and its variants dir
and vdir, which list information about files.
5.1 ls: List directory contentsList directory contents. 5.2 dir: Briefly list directory contentsBriefly ls. 5.3 vdir: Verbosely list directory contentsVerbosely ls. 5.4 dircolors: Color setup forlsColor setup for ls, etc.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ls: List directory contents
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 arguments are specified, ls lists the contents of the
current directory.
By default, the output is sorted alphabetically. 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.
The `-g' option is accepted but ignored, for compatibility with Unix. Also see 2. Common options.
5.1.1 Which files are listed 5.1.2 What information is listed 5.1.3 Sorting the output 5.1.4 More details about version sort 5.1.5 General output formatting 5.1.6 Formatting the file names
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options determine which files ls lists information for.
By default, any files and the contents of any directories on the command
line are shown.
$ 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 `#'.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options affect the information that ls displays. By
default, only file names are shown.
//DIRED// beg1 end1 beg2 end2 ... |
The begN and endN are unsigned integers that record the byte 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 contain unusual characters such as space or newline, without fancy searching.
If directories are being listed recursively (-R), output a similar
line after each subdirectory:
//SUBDIRED// format beg1 end1 ... |
Finally, output a line of the form:
//DIRED-OPTIONS// --quoting-style=word |
ls, so we
provide this option for compatibility.)
Warning: the meaning of `-H' will change in the future to conform to POSIX. Use `--si' for the old meaning.
make that
rely on file times.
For each directory that is listed, preface the files with a line `total blocks', where blocks is the total disk allocation for all files in that directory. The block size currently defaults to 1024 bytes, but this can be overridden (see section 2.2 Block size). The blocks computed counts each hard link separately; this is arguably a deficiency.
The permissions listed are similar to symbolic mode specifications
(see section 3.2 Symbolic Modes). But ls combines multiple bits into the
third character of each set of permissions as follows:
Following the permission bits is a single character that specifies whether an alternate access method applies to the file. When that character is a space, there is no alternate access method. When it is a printing character (e.g., `+'), then there is such a method.
ls.
Normally the disk allocation is printed in units of 1024 bytes, but this can be overridden (see section 2.2 Block size).
For 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-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 ls program.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 zeroes 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
|
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options affect the appearance of the overall output.
ls when standard
output is not a terminal.
ls if standard output is a terminal. It is always the default
for the dir and d programs.
GNU ls uses variable width columns to display as many files as
possible in the fewest lines.
more or
less usually produces unreadable results. However, using
more -f does seem to work.
date,
but this is planned to change in a future release, partly because modern
file time stamps have more precision. It's not
possible to change the format, but you can extract out the date string with
cut and then pass the result to date -d. See section `date invocation' in Shell utilities.
This is most useful because the time output includes the seconds. (Unix filesystems store file timestamps only to the nearest second, so this option shows all the information there is.) For example, this can help when you have a Makefile that is not regenerating files properly.
ls uses tabs where possible in the output, for efficiency. If
cols is zero, do not use tabs at all.
COLUMNS is used if it is set; otherwise the default
is 80.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options change how file names themselves are printed.
ls.
You can specify the default value of the `--quoting-style' option
with the environment variable QUOTING_STYLE. If that environment
variable is not set, the default value is `literal', but this
default may change to `shell' in a future version of this package.
ls.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
dir: Briefly list directory contents
dir (also installed as d) 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 section ls.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
vdir: Verbosely list directory contents
vdir (also installed as v) 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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
dircolors: Color setup for ls
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'.
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 2. Common options.
SHELL
environment variable is set and does not end with `csh' or
`tcsh'.
SHELL ends with
csh or tcsh.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes the commands for basic file manipulation: copying, moving (renaming), and deleting (removing).
6.1 cp: Copy files and directoriesCopy files. 6.2 dd: Convert and copy a fileConvert and copy a file. 6.3 install: Copy files and set attributesCopy files and set attributes. 6.4 mv: Move (rename) filesMove (rename) files. 6.5 rm: Remove files or directoriesRemove files or directories. 6.6 shred: Remove files more securelyRemove files more securely.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
cp: Copy files and directories
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.
Synopsis:
cp [option]... source dest cp [option]... source... directory |
If the last argument names an existing directory, cp copies each
source file into that directory (retaining the same name).
Otherwise, if only two files are given, it copies the first onto the
second. It is an error if the last argument is not a directory and more
than two non-option arguments are given.
Generally, files are written just as they are read. For exceptions, see the `--sparse' option below.
By default, cp does not copy directories. However, the
`-R', `-a', and `-r' 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
`--no-dereference' (`-d'), `--dereference'
(`-L'), and `-H' options. If more than one of these
options is specified, the last one silently overrides the others.
cp generally refuses to copy a file onto itself, with the
following exception: if `--force --backup' 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 section 2.1 Backup options). 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 2. Common options.
cp makes a backup of source when the force
and backup options are given and source and dest are the same
name for an existing, regular file. One useful application of this
combination of options is this tiny Bourne shell script:
#!/bin/sh # Usage: backup FILE... # Create a GNU-style backup of each listed FILE. for i in "$@"; do cp --backup --force "$i" "$i" done |
cp then unlinks it and
tries to open it again. Contrast this behavior with that enabled by
`--link' and `--symbolic-link', whereby the destination file
is never opened but rather is unlinked unconditionally. Also see the
description of `--remove-destination'.