Commit | Line | Data |
---|---|---|
1f6fd1a3 BJ |
1 | .TH LS 1 11/16/79 |
2 | .UC | |
3 | .SH NAME | |
4 | ls \- list contents of directory | |
5 | .SH SYNOPSIS | |
6 | .B ls | |
7 | [ | |
8 | .B \-ltasdruifgm1cqx | |
9 | ] name ... | |
10 | .br | |
11 | .B l | |
12 | [ \fIls\fR options ] name ... | |
13 | .SH DESCRIPTION | |
14 | For each directory argument, | |
15 | .I ls | |
16 | lists the contents of the directory; | |
17 | for each file argument, | |
18 | .I ls | |
19 | repeats its name and any other information requested. | |
20 | The output is sorted alphabetically by default. | |
21 | When no argument is given, the current directory is listed. | |
22 | When several arguments are given, | |
23 | the arguments are first sorted appropriately, | |
24 | but file arguments appear | |
25 | before directories and their contents. | |
26 | .PP | |
27 | There are three possible listing formats. | |
28 | The format chosen depends on whether the output is going | |
29 | to a teletype, and may also be controlled by option flags. | |
30 | The default format for a teletype is to list the contents of directories | |
31 | in multi-column format, with the entries sorted down the columns. | |
32 | (See also the | |
33 | .B \-x | |
34 | option below.) | |
35 | If the standard output is not a teletype, the default format is to | |
36 | list one entry per line. | |
37 | Finally, there is a stream output format in which files are listed | |
38 | across the page, separated by `,' characters. | |
39 | The | |
40 | .B \-m | |
41 | flag enables this format. | |
42 | .PP | |
43 | When invoked as | |
44 | .I l | |
45 | the default is | |
46 | .B \-m . | |
47 | .PP | |
48 | .B "Note:" | |
49 | Files which are not the contents of a directory being interpreted | |
50 | are always sorted across the page rather than down the page in columns. | |
51 | This is because the individual file names may be arbitrarily long. | |
52 | There are several options: | |
53 | .TP | |
54 | .B \-l | |
55 | List in long format, giving mode, number of links, owner, | |
56 | size in bytes, and time of last modification | |
57 | for each file. | |
58 | (See below.) | |
59 | If the file is a special file the size field will instead contain | |
60 | the major and minor device numbers. | |
61 | .TP | |
62 | .B \-t | |
63 | Sort by time modified (latest first) instead of | |
64 | by name, as is normal. | |
65 | .TP | |
66 | .B \-a | |
67 | List all entries; usually | |
68 | .RB ` . ' | |
69 | and | |
70 | .RB ` .. ' | |
71 | are suppressed. | |
72 | .TP | |
73 | .B \-s | |
74 | Give size in blocks, | |
75 | including indirect blocks, for each entry. | |
76 | .TP | |
77 | .B \-d | |
78 | If argument is a directory, list only its name, not | |
79 | its contents (mostly used with | |
80 | .B \-l | |
81 | to get status | |
82 | on directory). | |
83 | .TP | |
84 | .B \-r | |
85 | Reverse the order of sort to get reverse alphabetic | |
86 | or oldest first as appropriate. | |
87 | .TP | |
88 | .B \-u | |
89 | Use time of last access instead of last | |
90 | modification for sorting | |
91 | .RB ( \-t ) | |
92 | or printing | |
93 | .RB ( \-l ). | |
94 | .TP | |
95 | .B \-i | |
96 | Print i-number in first column | |
97 | of the report for each file listed. | |
98 | .TP | |
99 | .B \-f | |
100 | Force each argument to be interpreted as a directory | |
101 | and list the name found in each slot. | |
102 | This option turns off | |
103 | .B "\-l, \-t, \-s," | |
104 | and | |
105 | .B \-r, | |
106 | and | |
107 | turns on | |
108 | .B \-a; | |
109 | the order is the order in which entries | |
110 | appear in the directory. | |
111 | .TP | |
112 | .B \-g | |
113 | Give group ID instead of owner ID in long listing. | |
114 | .TP | |
115 | .B \-m | |
116 | force stream output format | |
117 | .TP | |
118 | .B \-1 | |
119 | force one entry per line output format, e.g. to a teletype | |
120 | .TP | |
121 | .B \-c | |
122 | force multi-column output, e.g. to a file or a pipe | |
123 | .TP | |
124 | .B \-q | |
125 | force printing of non-graphic characters in file names as | |
126 | the character `?'; this normally happens only if the output device is | |
127 | a teletype | |
128 | .TP | |
129 | .B \-x | |
130 | force columnar printing to be sorted across rather than | |
131 | down the page; | |
132 | this is the default if the last character of the name the program is invoked | |
133 | with is an `x'. | |
134 | .PP | |
135 | The mode printed under the | |
136 | .B \-l | |
137 | option contains 11 characters | |
138 | which are interpreted | |
139 | as follows: | |
140 | the first character is | |
141 | .TP 3 | |
142 | .B d | |
143 | if the entry is a directory; | |
144 | .br | |
145 | .ns | |
146 | .TP 3 | |
147 | .B b | |
148 | if the entry is a block-type special file; | |
149 | .br | |
150 | .ns | |
151 | .TP 3 | |
152 | .B c | |
153 | if the entry is a character-type special file; | |
154 | .br | |
155 | .ns | |
156 | .TP 3 | |
157 | .B \- | |
158 | if the entry is a plain file. | |
159 | .PP | |
160 | The next 9 characters are interpreted | |
161 | as three sets of three bits each. | |
162 | The first set refers to owner permissions; | |
163 | the next to permissions to others in the same user-group; | |
164 | and the last to all others. | |
165 | Within each set the three characters indicate | |
166 | permission respectively to read, to write, or to | |
167 | execute the file as a program. | |
168 | For a directory, `execute' permission is interpreted | |
169 | to mean permission to search the directory | |
170 | for a specified file. | |
171 | The permissions are indicated as follows: | |
172 | .TP 3 | |
173 | .B r | |
174 | if the file is readable; | |
175 | .br | |
176 | .ns | |
177 | .TP 3 | |
178 | .B w | |
179 | if the file is writable; | |
180 | .br | |
181 | .ns | |
182 | .TP 3 | |
183 | .B x | |
184 | if the file is executable; | |
185 | .br | |
186 | .ns | |
187 | .TP 3 | |
188 | .B \- | |
189 | if the indicated permission is not granted. | |
190 | .PP | |
191 | The group-execute permission character is given | |
192 | as | |
193 | .B s | |
194 | if the file has set-group-ID mode; | |
195 | likewise the user-execute permission character is given | |
196 | as | |
197 | .B s | |
198 | if the file has set-user-ID mode. | |
199 | .PP | |
200 | The last character of the mode (normally `x' or `\-') is | |
201 | .B t | |
202 | if the 1000 bit of the mode is on. | |
203 | See | |
204 | .IR chmod (1) | |
205 | for the meaning of this mode. | |
206 | .PP | |
207 | When the sizes of the files in a directory | |
208 | are listed, a total count of blocks, | |
209 | including indirect blocks is printed. | |
210 | .SH FILES | |
211 | /etc/passwd to get user ID's for | |
212 | `ls \-l'. | |
213 | .br | |
214 | /etc/group to get group ID's for | |
215 | `ls \-g'. | |
216 | .SH BUGS | |
217 | Newline and tab are considered printing characters in file names. | |
218 | .PP | |
219 | The output device is assumed to be 80 columns wide. | |
220 | Columns are basically 15 characters wide, 20 characters wide if | |
221 | .BR \-i " or " "\-s\fR is specified, 25 characters wide if both" | |
222 | .BR \-i " and " "\-s\fR are specified." | |
223 | In any case where | |
224 | .BR \-l "" | |
225 | or | |
226 | .BR \-n "" | |
227 | is specified, we assume | |
228 | only one entry will fit per line. | |
229 | .PP | |
230 | The option setting based on whether the output is a teletype is | |
231 | undesirable as: | |
232 | .PP | |
233 | .DT | |
234 | ls \-s | lpr | |
235 | .PP | |
236 | is much different than | |
237 | .PP | |
238 | ls \-s | |
239 | .PP | |
240 | On the other hand, not doing this setting would make old shell scripts | |
241 | which used | |
242 | .I ls | |
243 | almost certain losers, | |
244 | and then one could no longer do, e.g.: | |
245 | .PP | |
246 | ls \-s | sort \-nr | |
247 | .PP | |
248 | but would have to do | |
249 | .PP | |
250 | ls \-s \-1 | sort \-nr | |
251 | .PP | |
252 | Column widths choices are poor for terminals which can tab. |