make -f output look like standard outputs
[unix-history] / usr / src / bin / ls / ls.1
CommitLineData
a10206cc
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
f4382a2f 5.\" @(#)ls.1 6.8 (Berkeley) %G%
a10206cc 6.\"
4a3d96b7 7.TH LS 1 ""
a10206cc
KM
8.UC
9.SH NAME
10ls \- list contents of directory
11.SH SYNOPSIS
12.B ls
13[
ccc80378 14.B \-acdfgilqrstu1ACLFR
a10206cc
KM
15] name ...
16.br
a10206cc
KM
17.SH DESCRIPTION
18For each directory argument,
19.I ls
20lists the contents of the directory;
21for each file argument,
22.I ls
23repeats its name and any other information requested.
30149789 24By default, the output is sorted alphabetically.
a10206cc
KM
25When no argument is given, the current directory is listed.
26When several arguments are given,
27the arguments are first sorted appropriately,
30149789 28but file arguments are processed
a10206cc
KM
29before directories and their contents.
30.PP
30149789 31There are a large number of options:
a10206cc 32.TP
30149789 33.B \-l
a10206cc
KM
34List in long format, giving mode, number of links, owner,
35size in bytes, and time of last modification
36for each file.
37(See below.)
38If the file is a special file the size field will instead contain
39the major and minor device numbers.
30149789
KM
40If the file is a symbolic link the pathname of
41the linked-to file is printed preceded by ``\->''.
42.TP
43.B \-g
44Include the group ownership of the file in a long output.
a10206cc 45.TP
30149789 46.B \-t
a10206cc 47Sort by time modified (latest first) instead of
30149789 48by name.
a10206cc 49.TP
30149789
KM
50.B \-a
51List all entries; in the absence of this option, entries whose
52names begin with a period
53.RB ( . )
54are
55.I not
56listed.
a10206cc 57.TP
0a413117
KB
58.B \-A
59List all entries except for ``.'' and ``..''. Always set for the
60super-user.
61.TP
30149789
KM
62.B \-s
63Give size in kilobytes of each file.
a10206cc 64.TP
30149789
KM
65.B \-d
66If argument is a directory, list only its name;
67often used with \fB\-l\fR to get the status of a directory.
68.TP
69.B \-L
70If argument is a symbolic link, list the file or directory the link references
71rather than the link itself.
a10206cc 72.TP
30149789 73.B \-r
ccc80378
MK
74Reverse the order of sort to get reverse alphabetic
75or oldest first as appropriate.
a10206cc 76.TP
30149789 77.B \-u
a10206cc
KM
78Use time of last access instead of last
79modification for sorting
30149789
KM
80(with the \fB\-t\fP option)
81and/or printing (with the \fB\-l\fP option).
a10206cc 82.TP
30149789 83.B \-c
aa97bb7c 84Use time when file status was last changed for sorting or printing.
a10206cc 85.TP
30149789
KM
86.B \-i
87For each file, print the i-number in the first column of the report.
a10206cc 88.TP
30149789 89.B \-f
a10206cc
KM
90Force each argument to be interpreted as a directory
91and list the name found in each slot.
92This option turns off
f4382a2f 93.B "\-F, \-R, \-l, \-r, \-s,"
a10206cc 94and
f4382a2f 95.B \-t,
a10206cc
KM
96and
97turns on
98.B \-a;
99the order is the order in which entries
100appear in the directory.
101.TP
30149789
KM
102.B \-F
103cause directories to be marked with a trailing `/',
104sockets with a trailing `=',
105symbolic links with a trailing `@', and executable
106files with a trailing `*'.
a10206cc 107.TP
30149789
KM
108.B \-R
109recursively list subdirectories encountered.
a10206cc 110.TP
30149789
KM
111.B \-1
112force one entry per line output format; this is the default when
113output is not to a terminal.
a10206cc 114.TP
30149789
KM
115.B \-C
116force multi-column output; this is the default when output is to a terminal.
a10206cc 117.TP
30149789 118.B \-q
a10206cc 119force printing of non-graphic characters in file names as
30149789 120the character `?'; this is the default when output is to a terminal.
a10206cc
KM
121.PP
122The mode printed under the
123.B \-l
124option contains 11 characters
125which are interpreted
126as follows:
127the first character is
128.TP 3
30149789 129.B d
a10206cc
KM
130if the entry is a directory;
131.br
132.ns
133.TP 3
30149789 134.B b
a10206cc
KM
135if the entry is a block-type special file;
136.br
137.ns
138.TP 3
30149789 139.B c
a10206cc
KM
140if the entry is a character-type special file;
141.br
142.ns
143.TP 3
30149789
KM
144.B l
145if the entry is a symbolic link;
146.br
147.ns
148.TP
149.B s
150if the entry is a socket, or
a10206cc
KM
151.br
152.ns
153.TP 3
154.B \-
155if the entry is a plain file.
156.PP
157The next 9 characters are interpreted
158as three sets of three bits each.
159The first set refers to owner permissions;
adbdb3c0 160the next refers to permissions to others in the same user-group;
a10206cc
KM
161and the last to all others.
162Within each set the three characters indicate
163permission respectively to read, to write, or to
164execute the file as a program.
165For a directory, `execute' permission is interpreted
30149789 166to mean permission to search the directory.
a10206cc
KM
167The permissions are indicated as follows:
168.TP 3
169.B r
170if the file is readable;
171.br
172.ns
173.TP 3
174.B w
175if the file is writable;
176.br
177.ns
178.TP 3
179.B x
180if the file is executable;
181.br
182.ns
183.TP 3
184.B \-
185if the indicated permission is not granted.
186.PP
303dbd7d
KB
187The group-execute permission character is given as \fBs\fP if the file has
188the set-group-id bit set; likewise the user-execute permission character is
189given as \fBs\fP if the file has the set-user-id bit set. These are given
190as \fBS\fP (capitalized) if the corresponding execute permission is NOT
191set.
a10206cc
KM
192.PP
193The last character of the mode (normally `x' or `\-') is
194.B t
195if the 1000 bit of the mode is on.
196See
197.IR chmod (1)
303dbd7d
KB
198for the meaning of this mode. This is given as \fBT\fP (capitalized) if the
199corresponding execute permission is NOT set.
a10206cc
KM
200.PP
201When the sizes of the files in a directory
202are listed, a total count of blocks,
203including indirect blocks is printed.
204.SH FILES
30149789 205/etc/passwd to get user id's for
a10206cc
KM
206`ls \-l'.
207.br
30149789 208/etc/group to get group id's for
a10206cc
KM
209`ls \-g'.
210.SH BUGS
211Newline and tab are considered printing characters in file names.
212.PP
213The output device is assumed to be 80 columns wide.
214.PP
215The option setting based on whether the output is a teletype is
216undesirable as ``ls\ \-s'' is much different than ``ls\ \-s\ |\ lpr''.
217On the other hand, not doing this setting would make old shell scripts
218which used
219.I ls
220almost certain losers.