-
Notifications
You must be signed in to change notification settings - Fork 1
/
ls.1
330 lines (247 loc) · 13.2 KB
/
ls.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
LS(1) Human68k ITA TOOLBOX User's Manual LS(1)
名称
ls - ファイルやディレクトリの情報を出力する
形式
ls [ -1ABCDEFGLPQRSUVXabdeflmpqrstvx ] [ -w cols ] [ -- ]
[ name ] ...
解説
ls はファイルやディレクトリの情報を標準出力に出力します.
引数 [ name ] ... は対象のファイルやディレクトリのパス名の並
びです.
ファイル引数を与えると,そのパス名と情報が出力されます.
ディレクトリ引数を与えると,そのディレクトリ内のすべてのファ
イルの名前と情報がソートされて出力されます.ただしデフォルト
では,‘.’で始まる名前のエントリ,ボリューム・ラベル,およ
び隠しファイルは出力されません.それらは -A オプションや -a
オプションによって出力されるようになります.
‘.’と‘..’は特別に処理されます.これらの FAT上の情報は無
視されて,これらが指すディレクトリの情報が参照されます.
‘A:’のようなドライブ名のみの引数は,そのドライブのカレント・
ディレクトリを意味します.
引数がディレクトリへのシンボリック・リンクであった場合,-l
オプションや -v オプションが指定されているときにはリンクその
ものの情報が出力され,そうでなければディレクトリ引数として処
理されます.引数の末尾に‘/’が付加されていれば,-l オプショ
ンや -v オプションが指定されていてもディレクトリ引数として処
理されます.
複数の引数を与えた場合,結果はソートされて出力されます.ただ
しファイル引数はディレクトリ引数よりも先に出力されます.引数
として与えた名前のファイルやディレクトリが存在しなければ標準
エラー出力に報告されますが,処理は最後まで続行されます.引数
を省略すると‘.’を指定したことになります.
ソートは,デフォルトでは名前のアルファベット順です.大文字と
小文字は区別されます.-X,-t,-S,-U,-D,-r オプションでソー
トの方式を変更・調整することができます.
ls は主に 4つの出力形式を持っています.これは -1,-C,-x,-m
オプションで選択することができます.-1 オプションの形式は 1
行に 1つのエントリを出力し,その他の形式は 1行に複数のエント
リを出力します.デフォルトでは,出力がキャラクタ・デバイスで
あるときには -C オプション形式,そうでなければ -1 オプション
形式となります.この 4つの形式の他に,特別な出力形式としてロ
ング・フォーマット出力形式が用意されています.これは -l オプ
ションかまたは -v オプションで選択されます.
一行の複数のエントリを出力する場合に想定される出力行の幅は
-w オプションで指定します.-w オプションを省略すると,環境変
数 COLUMNS に設定されている値が取られます.それも設定されて
いない場合のデフォルトは 80桁です.
ls には次のオプションがあります.
-1 1行に 1エントリの形式で出力します.
-A ディレクトリの内容を出力するとき,‘.’で始まる名
前のエントリや隠しファイルも出力します.ただし
‘.’,‘..’,およびボリューム・ラベルは出力しま
せん.
-B ディレクトリの内容を出力するとき,名前の末尾が‘~’
または‘.BAK’であるエントリを出力しません.(大文
字と小文字は区別されません)
-C 1行に複数のエントリを出力します.エントリは縦方向
に並びます.各エントリ間の間隔は一番長いエントリに
合わせて整形されます.
-D エントリを名前でソートする場合,大文字と小文字を区
別しません.綴りが同一である場合には大文字が先にな
ります.
-E エントリの名前を色付き表示します.このオプションは
出力がキャラクタ・デバイスでない場合には無視されま
す.
環境変数 LSCOLORS に設定されている制御シーケンスを
エントリ名の直前に付加出力することによって色付けが
行われます.環境変数 LSCOLORS の値は‘:’で区切ら
れた 4つのフィールドからなり,2番目のフィールドは
ディレクトリ,3番目のフィールドは実行可能ファイル,
4番目のフィールドはシンボリック・リンク,そして最
初のフィールドはそれ以外のエントリに対する制御シー
ケンスです.環境変数 LSCOLORS が設定されていない場
合のデフォルトは‘^[[m:^[[31m:^[[32m:^[[43m’です.
エントリ名の直後には‘^[[m’が出力されます.なお,
‘^[’は‘^’と‘[’の 2文字ではなく,生のESCコー
ド(0x1b)です.
-F -p オプションの機能に加え,エントリが実行可能ファ
イルならば‘*’を名前の後ろに付加出力します.この
オプションは -p オプションを覆います.
-G ディレクトリの内容を出力するとき,ディレクトリと非
ディレクトリを別個にソートし,ディレクトリを先に出
力します.
-L シンボリック・リンクの情報を,その参照ファイルの情
報で置き替えます.
-P -p オプションの機能に加え,エントリがディレクトリ
を指すシンボリック・リンクならば‘>’,ディスク上
に実体を持たないシンボリック・リンクならば‘&’を
名前の後ろに付加出力します.それ以外のシンボリック・
リンクには -p オプションと同様に‘@’を付加出力し
ます.このオプションは -p オプションを覆います.
-Q エントリの名前を "" で囲って出力します.
-R 出力したディレクトリ内にサブディレクトリ(‘.’と
‘..’は除きます)があれば,そのサブディレクトリの
内容を再帰的に出力します.
-S サイズ(バイト数)の大きい順にソートします.
-U ソートしません.エントリが検索された順に出力します.
-V ディレクトリのサイズ(バイト数)を(セクタ数×セク
タあたりのバイト数)とします.
-X 拡張子のアルファベット順にソートします.拡張子の綴
りが同一である場合には名前全体で比較します.-D オ
プションを指定しなければ,大文字と小文字は区別され
ます.-D オプションを指定すると大文字と小文字は区
別されなくなります.このとき,拡張子の綴りが同一で
あっても,拡張子の大文字と小文字は区別されず,名前
全体が優先されます.たとえば‘a.b’と‘b.B’ とで
は‘a.b’が先になります.
-a ディレクトリの内容を出力するとき,すべてのエントリ
を出力します.このオプションは -A オプションを覆い
ます.
-b エントリの名前の中に制御文字やスペースなど‘見えな
い文字’がある場合,その文字を出力する代わりに‘\’
に続けてその文字コードを表す 3桁の 8進数を出力しま
す.
-d ディレクトリ引数もファイル引数と見なします.つまり,
ディレクトリの内容を出力するのではなく,そのディレ
クトリ自体の情報を出力します.
-e ファイルやディレクトリを正確にトレースします.
標準の Human68k はファイル名の大文字と小文字
を区別せず,また,拡張子を除いたファイル名の
9文字目以降を照合しません.したがって,たとえ
ば引数‘EXPLORAT’でもファイル‘exploration’
が検索されるわけですが,このとき ls は
‘EXPLORAT’と出力し,この名前でソートするこ
とになります.-e オプションを指定すれば,この
場合も正しく‘exploration’と出力します.また,
たとえば引数‘/a/../b’を与えたとき,通常は
‘/a’が存在していなくても‘/b’が存在してい
ればエラーになりませんが,このオプションを指
定すれば,それはエラーとなります.ただし‘.’
および‘..’そのものが存在するかどうかは
チェックしません.存在していようといまいと
‘.’は常にカレント・ディレクトリを表し,
‘..’は常にその親ディレクトリを表します.
-f -a,-e,-U オプションをセットします.-B,-R,-d,
-L,-p,-F,-s,-l,-v オプションの指定は無効とな
ります.
-l 1行に 1エントリずつ,ロング・フォーマットで出力し
ます.また,ディレクトリの内容を出力するときには,
それら出力エントリのブロック数の合計を出力します.
このオプションは -1,-C,-x,-m オプションを覆いま
す.
各行は,エントリの属性,サイズ(バイト数),最終更
新時刻,名前の順に出力されます.属性は 7桁のシンボ
ルで表されます.1桁目は次の 4種類の文字のうちいず
れかでエントリの種別を示します.
v ボリューム・ラベル
d ディレクトリ
l シンボリック・リンク
- 通常のファイル
残りの 6桁はそれぞれ次の付随属性を示します.
2桁目 a 保管ファイル
3桁目 s システム・ファイル
4桁目 h 隠しファイル
5桁目 r 読み出し可
6桁目 w 書き込み可
7桁目 x 実行可
各桁では,その付随属性がオンであれば上記の文字を出
力し,オフであれば‘-’を出力します.
最終更新時刻は,6ヶ月を経過していないファイルは
‘Dec 1 21:26’のように‘月 日 時:分’の形式で出
力し,6ヶ月を経過したファイルや未来のファイルは
‘May 30 1990’のように‘月 日 年’の形式で出力し
ます.
エントリがシンボリック・リンクであると,名前に続い
て‘ -> 参照パス名’を出力します.このとき -F オプ
ションや -p オプションはリンクそのものではなく参照
パス名に対して働きます.
-m エントリを‘, ’で連結して出力します.
-p エントリがディレクトリならば‘/’,シンボリック・
リンクならば‘@’を,名前の後ろに付加出力します.
-q エントリの名前の中に制御文字やスペースなど‘見えな
い文字’がある場合,その文字を出力する代わりに‘?’
を出力します.
-r ソートの順序を逆にします.
-s 各エントリのブロック数を付加出力します.ディレクト
リの内容を出力するときには,それら出力エントリのブ
ロック数の合計も出力します.
-t 最終更新時刻の新しい順にソートします.
-v -l オプションとほぼ同じですが,最終更新時刻を
‘1990-05-05 00:00:00’のように‘年-月-日 時:分:秒’
の形式で出力します.
-w cols 一行の複数のエントリを出力する場合に,出力行の幅を
cols と想定し,これを超えない前に改行を出力します.
-w オプションを複数指定した場合には,最後の指定が
有効となります.-w オプションが指定されていない場
合は,環境変数 COLUMNS に設定されている値が出力行
の幅となります.それも設定されていない場合には 80
桁がデフォルトとなります.
-x -C オプションとほぼ同じですが,エントリは横方向に
並びます.
補足
ここで言う実行可能ファイルとは,エントリがファイルとして存在
し,かつ,その属性の実行可能ビット(第7ビット)が 1であるか
または名前の末尾が‘.X’または‘.R’であるファイルです(大文
字と小文字は区別されません).
環境変数
COLUMNS 出力行の幅
LSCOLORS -E オプションで使用される制御シーケンス
関連事項
chmod(1), find(1), du(1)
lndrv(1), LINK_FILES(3), ln.doc, ln_tech.doc (by Masaru Oki)
TwentyOne(8)
診断
何らかのエラーがあったときにはエラー・メッセージが標準エラー
出力に出力されます.
終了ステータスとしては,引数の記述に間違いがあった場合には 1,
各引数の処理中に何らかのエラーが 1度でもあった場合には 2,メ
モリ不足や OS のバージョンの違いなど,システムの原因により正
常に実行ができなかった場合には 3,すべてが正常に終了したなら
ば 0 が返ります.^C などによって中断したときの終了ステータス
は OS の仕様によります.
注意
システムに沖版シンボリック・リンク lndrv が組み込まれていな
いと,シンボリック・リンクの参照先の情報は得られません.
-s,-l,-v オプションで出力されるブロック数は目安でしかあり
ません.ディレクトリとボリューム・ラベルのブロック数は,実際
にディスク上に占めているセクタ数です.それら以外の通常のファ
イルについては,1ブロック=1024バイトとして計算で求められま
す.
ディレクトリの内容を出力する場合に -s,-l,-v オプションで出
力される total ブロック数は,必ずしもディスクの使用状況に一
致しないことに注意してください.この数字はあくまでも出力する
各エントリのブロック数の合計であり,-a,-A,-B オプションの
指定に左右されます.
引数として与えた名前に含まれるドライブ名は,ソートにもそのま
ま利用されます.たとえばデフォルトのソートでは‘A:’と‘B:’
とでは‘A:’が先になりますが,‘a:’と‘B:’とでは‘B:’が先
になります.‘/’と‘\’とについても同様に注意してください.
ただし,‘/’および‘\’の連続は最初の 1文字に置き替えられま
す.引数がルート・ディレクトリでなければ,末尾の‘/’や‘\’
は除去されます.
不具合
-b,-q オプションは,見えないマルチバイト文字には対応してい
ません.
‘.’と‘..’の FAT上の情報を知る手段は用意されていません.
各ドライブ(仮想ドライブを含む)のルート・ディレクトリは,属
性は‘d---rw-’,サイズは 0,最終更新時刻は 0年 1月 1日 0時
0分 0秒と見なして処理されます.
出力行の幅に収まらないエントリがある場合には行の幅を超えて改
行が出力されます.
-E オプションの機能は termcap あるいは terminfo に沿う形に置
き替わるべきです.
バージョン
1.5
制作・著作
Copyright(C)1992-94 by 板垣 史彦 (Itagaki Fumihiko)
1.5 Last change: 23 Dec 1994 Itagaki Fumihiko