Commit | Line | Data |
---|---|---|
bb3f0319 BJ |
1 | .th LS VI 9/3/77 |
2 | .sh NAME | |
3 | ls \- list contents of directory | |
4 | .sh SYNOPSIS | |
5 | .bd ls | |
6 | [ | |
7 | .bd \-lntasdruifm1cqx | |
8 | ] name ... | |
9 | .sh DESCRIPTION | |
10 | For each directory argument, | |
11 | .it ls | |
12 | lists the contents of the directory; | |
13 | for each file argument, | |
14 | .it ls | |
15 | repeats its name and any other information requested. | |
16 | The output is sorted alphabetically by default. | |
17 | When no argument is given, the current directory is listed. | |
18 | When several arguments are given, | |
19 | the arguments are first sorted appropriately, | |
20 | but file arguments appear | |
21 | before directories and their contents. | |
22 | .s3 | |
23 | .it Ls | |
24 | has three possible listing formats. | |
25 | The format chosen depends on whether the output is going | |
26 | to a teletype, and may also be controlled by option flags. | |
27 | The default format for a teletype is to list the contents of directories | |
28 | in multi-column format, with the entries sorted down the columns. | |
29 | (See also the | |
30 | .bd \-x | |
31 | option below.) | |
32 | If the standard output is not a teletype, the default format is to | |
33 | list one entry per line. | |
34 | This is the way older versions of | |
35 | .it ls | |
36 | worked. | |
37 | Finally, there is a stream output format in which files are listed | |
38 | across the page, separated by `,' characters. | |
39 | The | |
40 | .bd \-m | |
41 | flag enables this format. | |
42 | .s3 | |
43 | .bd "Important note:" | |
44 | Files which are not the contents of a directory being interpreted | |
45 | are always sorted across the page rather than down the page in columns. | |
46 | This is because the individual file names may be arbitrarily long. | |
47 | .s3 | |
48 | There are scads of options: | |
49 | .s3 | |
50 | .lp +4 4 | |
51 | \fB\-l\fR list in long format, giving mode, number of links, owner, | |
52 | size in bytes, and time of last modification | |
53 | for each file. | |
54 | (See below.) | |
55 | If the file is a special file the size field will instead contain | |
56 | the major and minor device numbers. | |
57 | .s3 | |
58 | .lp +4 4 | |
59 | \fB\-n\fR long format like \fB\-l\fR but without looking up the string | |
60 | name of the owner; the owner is given as decimal group and user id. | |
61 | This is much faster on a system with a large password file when many | |
62 | different people own the files being | |
63 | listed. | |
64 | .s3 | |
65 | .lp +4 4 | |
66 | \fB\-t\fR sort by time modified (latest first) instead of | |
67 | by name, as is normal | |
68 | .s3 | |
69 | .lp +4 4 | |
70 | \fB\-a\fR list all entries; usually those beginning with `\fB.\fR' are | |
71 | suppressed | |
72 | .s3 | |
73 | .lp +4 4 | |
74 | \fB\-s\fR give size in blocks for each entry. | |
75 | If l is also specified the size in blocks | |
76 | appears after the size in bytes. | |
77 | .s3 | |
78 | .lp +4 4 | |
79 | \fB\-d\fR if argument is a directory, list only its name, not | |
80 | its contents (mostly used with | |
81 | .bd \-l | |
82 | to get status | |
83 | on directory) | |
84 | .s3 | |
85 | .lp +4 4 | |
86 | \fB\-r\fR reverse the order of sort to get reverse alphabetic | |
87 | or oldest first as appropriate | |
88 | .s3 | |
89 | .lp +4 4 | |
90 | \fB\-u\fR use time of last access instead of last | |
91 | modification for sorting (\fB\-t\fR) or printing | |
92 | (\fB\-l\fR) | |
93 | .s3 | |
94 | .lp +4 4 | |
95 | \fB\-i\fR print i-number in first column | |
96 | of the report for each file listed | |
97 | .s3 | |
98 | .lp +4 4 | |
99 | \fB\-f\fR force each argument to be interpreted as a directory | |
100 | and list the name found in each slot. | |
101 | This option turns off | |
102 | .bd \-l, | |
103 | .bd \-t, | |
104 | .bd \-s, | |
105 | and | |
106 | .bd \-r, | |
107 | and | |
108 | turns on | |
109 | .bd \-a; | |
110 | the order is the order in which entries | |
111 | appear in the directory. | |
112 | .s3 | |
113 | .lp +4 4 | |
114 | \fB\-m\fR force stream output format | |
115 | .s3 | |
116 | .lp +4 4 | |
117 | \fB\-1\fR force one entry per line output format, e.g. to a teletype | |
118 | .s3 | |
119 | .lp +4 4 | |
120 | \fB\-c\fR force multi-column output, e.g. to a file or a pipe | |
121 | .s3 | |
122 | .lp +4 4 | |
123 | \fB\-q\fR force printing of non-graphic characters in file names as | |
124 | the character `?'; this normally happens only if the output device is | |
125 | a teletype | |
126 | .s3 | |
127 | .lp +4 4 | |
128 | \fB\-x\fR force columnar printing to be sorted across rather than | |
129 | down the page; | |
130 | this is the default if the last character of the name the program is invoked | |
131 | with is not an `l' or an `s'. | |
132 | .s3 | |
133 | .i0 | |
134 | The mode printed under the | |
135 | .bd \-l | |
136 | option contains 7 characters | |
137 | which are interpreted | |
138 | as follows: | |
139 | the first character is | |
140 | .s3 | |
141 | .lp +3 3 | |
142 | \fBd\fR if the entry is a directory; | |
143 | .lp +3 3 | |
144 | \fBq\fR if the entry is a quota file; | |
145 | .lp +3 3 | |
146 | \fBb\fR if the entry is a block-type special file; | |
147 | .lp +3 3 | |
148 | \fBc\fR if the entry is a character-type special file; | |
149 | .lp +3 3 | |
150 | \fB\-\fR if the entry is a plain file. | |
151 | .s3 | |
152 | .i0 | |
153 | The next 6 characters are interpreted | |
154 | as two sets of three bits each. | |
155 | The first set refers to owner permissions; | |
156 | and the second to others. | |
157 | Within each set the three characters indicate | |
158 | permission respectively to read, to write, or to | |
159 | execute the file as a program. | |
160 | For a directory, `execute' permission is interpreted | |
161 | to mean permission to search the directory | |
162 | for a specified file. | |
163 | The permissions are indicated as follows: | |
164 | .s3 | |
165 | .lp +3 3 | |
166 | \fBr\fR if the file is readable | |
167 | .lp +3 3 | |
168 | \fBw\fR if the file is writable | |
169 | .lp +3 3 | |
170 | \fBx\fR if the file is executable | |
171 | .lp +3 3 | |
172 | \fB\-\fR if the indicated permission is not granted | |
173 | .s3 | |
174 | .i0 | |
175 | The user-execute permission character is given | |
176 | as | |
177 | .bd s | |
178 | if the file has set-user-ID mode. | |
179 | .s3 | |
180 | The last character of the mode is printed as | |
181 | ``t'' if the 1000 bit of the mode is on. | |
182 | See | |
183 | .it "chmod (I)" | |
184 | for the current meaning of this mode. | |
185 | .sh FILES | |
186 | /etc/passwd to get user ID's for | |
187 | \fBls \-l\fR. | |
188 | .sh BUGS | |
189 | Newline and tab are considered printing characters in file names. | |
190 | .s3 | |
191 | Output device is assumed to be 80 columns wide. | |
192 | Columns are basically 15 characters wide, 20 characters wide if | |
193 | \fB\-i\fR or \fB\-s\fR is specified, 25 characters wide if both | |
194 | \fB\-i\fR and \fB\-s\fR are specified. | |
195 | In any case where \fB\-l\fR or \fB\-n\fR is specified, we assume | |
196 | only one entry will fit per line. | |
197 | .s3 | |
198 | The option setting based on whether the output is a teletype is | |
199 | undesirable as: | |
200 | .s3 | |
201 | .dt | |
202 | ls \-s | lpr | |
203 | .s3 | |
204 | is much different than | |
205 | .s3 | |
206 | ls \-s | |
207 | .s3 | |
208 | On the other hand, not doing this setting would make old shell scripts | |
209 | which used | |
210 | .it ls | |
211 | almost certain losers, | |
212 | and then one could no longer do, e.g.: | |
213 | .s3 | |
214 | ls \-s | sort \-nr | |
215 | .s3 | |
216 | but would have to do | |
217 | .s3 | |
218 | ls \-s \-1 | sort \-nr |