fix make clean and add make depend
[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.\"
7f5a7d0f 5.\" @(#)ls.1 6.2 (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[
7f5a7d0f 14.B \-acdfgilqrstu1ACLFRS
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
7f5a7d0f
JB
50.B \-S
51Sort by size (biggest first) instead of
52by name.
53This option turns on
54.BR \-s .
55If both
56.B \-t
57and
58.B \-S
59are given,
60.B \-t
61overrides
62(e.g. sorting is done by time).
63.TP
30149789
KM
64.B \-a
65List all entries; in the absence of this option, entries whose
66names begin with a period
67.RB ( . )
68are
69.I not
70listed.
a10206cc 71.TP
30149789
KM
72.B \-s
73Give size in kilobytes of each file.
a10206cc 74.TP
30149789
KM
75.B \-d
76If argument is a directory, list only its name;
77often used with \fB\-l\fR to get the status of a directory.
78.TP
79.B \-L
80If argument is a symbolic link, list the file or directory the link references
81rather than the link itself.
a10206cc 82.TP
30149789 83.B \-r
7f5a7d0f
JB
84Reverse the order of sort to get reverse alphabetic,
85size, or oldest first as appropriate.
a10206cc 86.TP
30149789 87.B \-u
a10206cc
KM
88Use time of last access instead of last
89modification for sorting
30149789
KM
90(with the \fB\-t\fP option)
91and/or printing (with the \fB\-l\fP option).
a10206cc 92.TP
30149789 93.B \-c
a10206cc
KM
94Use time of file creation for sorting or printing.
95.TP
30149789
KM
96.B \-i
97For each file, print the i-number in the first column of the report.
a10206cc 98.TP
30149789 99.B \-f
a10206cc
KM
100Force each argument to be interpreted as a directory
101and list the name found in each slot.
102This option turns off
7f5a7d0f 103.B "\-t, \-S,"
a10206cc
KM
104and
105.B \-r,
106and
107turns on
108.B \-a;
109the order is the order in which entries
110appear in the directory.
111.TP
30149789
KM
112.B \-F
113cause directories to be marked with a trailing `/',
114sockets with a trailing `=',
115symbolic links with a trailing `@', and executable
116files with a trailing `*'.
a10206cc 117.TP
30149789
KM
118.B \-R
119recursively list subdirectories encountered.
a10206cc 120.TP
30149789
KM
121.B \-1
122force one entry per line output format; this is the default when
123output is not to a terminal.
a10206cc 124.TP
30149789
KM
125.B \-C
126force multi-column output; this is the default when output is to a terminal.
a10206cc 127.TP
30149789 128.B \-q
a10206cc 129force printing of non-graphic characters in file names as
30149789 130the character `?'; this is the default when output is to a terminal.
a10206cc
KM
131.PP
132The mode printed under the
133.B \-l
134option contains 11 characters
135which are interpreted
136as follows:
137the first character is
138.TP 3
30149789 139.B d
a10206cc
KM
140if the entry is a directory;
141.br
142.ns
143.TP 3
30149789 144.B b
a10206cc
KM
145if the entry is a block-type special file;
146.br
147.ns
148.TP 3
30149789 149.B c
a10206cc
KM
150if the entry is a character-type special file;
151.br
152.ns
153.TP 3
30149789
KM
154.B l
155if the entry is a symbolic link;
156.br
157.ns
158.TP
159.B s
160if the entry is a socket, or
a10206cc
KM
161.br
162.ns
163.TP 3
164.B \-
165if the entry is a plain file.
166.PP
167The next 9 characters are interpreted
168as three sets of three bits each.
169The first set refers to owner permissions;
170the next to permissions to others in the same user-group;
171and the last to all others.
172Within each set the three characters indicate
173permission respectively to read, to write, or to
174execute the file as a program.
175For a directory, `execute' permission is interpreted
30149789 176to mean permission to search the directory.
a10206cc
KM
177The permissions are indicated as follows:
178.TP 3
179.B r
180if the file is readable;
181.br
182.ns
183.TP 3
184.B w
185if the file is writable;
186.br
187.ns
188.TP 3
189.B x
190if the file is executable;
191.br
192.ns
193.TP 3
194.B \-
195if the indicated permission is not granted.
196.PP
197The group-execute permission character is given
198as
199.B s
30149789 200if the file has the set-group-id bit set;
a10206cc
KM
201likewise the user-execute permission character is given
202as
203.B s
30149789 204if the file has the set-user-id bit set.
a10206cc
KM
205.PP
206The last character of the mode (normally `x' or `\-') is
207.B t
208if the 1000 bit of the mode is on.
209See
210.IR chmod (1)
211for the meaning of this mode.
212.PP
213When the sizes of the files in a directory
214are listed, a total count of blocks,
215including indirect blocks is printed.
216.SH FILES
30149789 217/etc/passwd to get user id's for
a10206cc
KM
218`ls \-l'.
219.br
30149789 220/etc/group to get group id's for
a10206cc
KM
221`ls \-g'.
222.SH BUGS
223Newline and tab are considered printing characters in file names.
224.PP
225The output device is assumed to be 80 columns wide.
226.PP
227The option setting based on whether the output is a teletype is
228undesirable as ``ls\ \-s'' is much different than ``ls\ \-s\ |\ lpr''.
229On the other hand, not doing this setting would make old shell scripts
230which used
231.I ls
232almost certain losers.