about summary refs log tree commit diff
path: root/lr.1
blob: 608a7a4a81f89bc9cb3101780f79f7555b10a538 (plain) (blame)
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
.Dd December 5, 2019
.Dt LR 1
.Os
.Sh NAME
.Nm lr
.Nd list files, recursively
.Sh SYNOPSIS
.Nm
.Op Fl 0 | Fl F | Fl l Oo Fl TA | Fl TC | Fl TM Oc | Fl S | Fl f Ar fmt
.br
.Op Fl B | Fl D
.Op Fl H | Fl L
.Op Fl 1AGPQXdhsx
.Op Fl U | Fl o Ar ord
.br
.Op Fl e Ar regex
.Op Fl t Ar test
.Op Fl C Oo Ar color Ns Li \&: Oc Ns Ar path
.Ar path\ ...
.Sh DESCRIPTION
.Nm
is a versatile tool to generate file listings with configurable
formatting, ordering and filtering.
.Pp
When no
.Ar path
is given or
.Ar path
is an empty string, the current directory is used by default.
.Pp
The special
.Ar path
argument
.Sq Ic \&\-
makes
.Nm
read file names from standard input,
instead of traversing
.Ar path .
Likewise, the special
.Ar path
argument
.Ic \&@ Ns Ar file
makes
.Nm
read file names from
.Ar file .
.Pp
By default,
.Nm
traverses directories before their entries.
When
.Fl D
is used, the subdirectories (and files) are traversed first.
When
.Fl B
is used, each level of depth is traversed before moving deeper.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl 0
Output filenames separated by NUL bytes.
Likewise, read input filenames separated by NUL bytes.
.It Fl 1
Don't go below one level of directories.
.It Fl A
Don't list files starting with a dot.
.It Fl B
Use breadth first traversal.
For each depth of the directory tree,
files are sorted and printed,
then the next depth is looked at.
.It Fl C Oo Ar color Ns Li \&: Oc Ns Ar path
Behaves as if
.Ar path
was passed like an ordinary argument,
but overrides the color of the file names to the number
.Ar color
which must be between 0 and 255
.Po
default: 2, green
.Pc .
.Pp
Implies
.Fl GG .
.It Fl D
Use depth first traversal.
.Ic prune
will not work, but
.Ic entries
and
.Ic total
are computed on the fly.
.It Fl F
Output filenames and an indicator of their file type
.Po
one of
.Sq Li */=>@\&|
.Pc .
.It Fl G
Colorize output to TTY.
Use twice to force colorized output.
If the environment variable
.Ev NO_COLOR
is set, colors are never used.
.It Fl H
Only follow symlinks on command line
.Po
default: don't follow symlinks
.Pc .
.It Fl L
Follow all symlinks.
.It Fl P
Quote file names using
Austin Group #249 syntax
.Li \&$' Ns No ... Ns Li \&'
.Po
implies
.Fl Q
.Pc .
.It Fl Q
Quote file names
.Po
default for output to TTY
.Pc .
.It Fl S
Output inspired by
BSD
.Xr stat 1
.Po
implies
.Fl Q
.Pc .
.It Fl TA
With
.Fl l ,
print atime.
.It Fl TC
With
.Fl l ,
print ctime.
.It Fl TM
With
.Fl l ,
print mtime.
This is the default.
.It Fl U
Don't sort results.
.It Fl X
Output OSC 8 hyperlinks to TTY.
Use twice to force hyperlinks.
.It Fl d
Don't enter directories.
.It Fl e Ar regex
Only show files where basename matches the POSIX ERE
.Ar regex .
.It Fl f Ar fmt
Custom formatting, see
.Sx FORMATTING .
.It Fl h
Print human readable size for
.Fl l
.Po
also
.Ic %s
.Pc .
.It Fl l
Long output a la
.Sq Ic ls -l
.Po
implies
.Fl Q
.Pc .
.It Fl o Ar ord
Sort according to
.Ar ord ,
see
.Sx SORT ORDER .
.It Fl s
Strip directory prefix passed on command line.
.It Fl t Ar test
Only show files matching the expression
.Ar test ,
see
.Sx TESTS .
Multiple occurrences of
.Fl t
and
.Fl e
are regarded as a conjunction.
.It Fl x
Don't enter other filesystems.
.El
.Sh FORMATTING
.Nm
format strings support the following escape sequences:
.Pp
.Bl -tag -compact -width Ds
.It Ic \ea , \eb , \ef , \en , \er , \ev
Special characters as in C
.It Ic \e Ns Ar ddd
Byte with one, two or three-digit octal value
.It Ic \ex Ns Ar dd
Byte with one or two-digit hexadecimal value
.It Ic \&%%
A plain
.Sq % .
.It Ic \&%s
File size in bytes
.It Ic \&%S
File size, with human readable unit
.It Ic \&%b
File size in 512-byte blocks
.It Ic \&%k
File size in 1024-byte blocks
.It Ic \&%d
Path depth
.It Ic \&%D
Device number
.Po
.Va stat.st_dev
.Pc
.It Ic \&%R
Device ID for special files
.Po
.Va stat.st_rdev
.Pc
.It Ic \&%i
Inode number
.It Ic \&%I
One space character for every depth level
.It Ic \&%p
Full path
.Po
.Ic \&%P
if
.Fl s
is used
.Pc
.It Ic \&%P
Full path without command line argument prefix
.It Ic \&%l
Symlink target
.It Ic \&%n
Number of hardlinks
.It Ic \&%F
File indicator type symbol
.Po
one of
.Sq Li */=>@\&|
.Pc
.It Ic \&%f
File basename
.Po
everything after last
.Li /
.Pc
.It Ic \&%A- , %C- , %T-
relative age for atime/ctime/mtime.
.It Ic \&%A Ns Ar x , Ic \&%C Ns Ar x , Ic \&%T Ns Ar x
result of
.Xr strftime 3
for
.Ic \&% Ns Ar x
on atime/ctime/mtime
.It Ic \&%m
Octal file permissions
.It Ic \&%M
ls-style symbolic file permissions
.It Ic \&%y
ls-style symbolic file type
.Po
.Sq Li bcdfls
.Pc
.It Ic \&%g
Group name
.It Ic \&%G
Numeric gid
.It Ic \&%u
User name
.It Ic \&%U
Numeric uid
.It Ic \&%e
Number of entries in directories
.It Ic \&%t
Total size used by accepted files in directories
.Po
only with
.Fl D
.Pc
.It Ic \&%Y
Type of the filesystem the file resides on
.It Ic \&%x
Linux-only:
Print a combination of
.Sq Li \&#
for files with security capabilities,
.Sq Li \&+
for files with an ACL,
.Sq Li \&@
for files with other extended attributes
.El
.Sh SORT ORDER
Sort order is string consisting of the following letters.
Uppercase letters reverse sorting.
Default sort order is
.Sq Ic n .
.Pp
.Bl -tag -compact -width Ds
.It Ic a
atime
.It Ic c
ctime
.It Ic d
path depth
.It Ic e
file extension
.It Ic i
inode number
.It Ic m
mtime
.It Ic n
file name
.It Ic p
directory name
.It Ic s
file size
.It Ic t
file type.
This sorts all directories before other files.
.It Ic v
File name as version numbers
.Po
sorts
.Sq 2
before
.Sq 10
.Pc .
.El
.Pp
E.g.\&
.Sq Ic Sn
sorts first by size, smallest last, and then by name
.Po
in case sizes are equal
.Pc .
.Sh TESTS
.Nm
tests are given by the following EBNF:
.Bd -literal
<expr>     ::= <expr> || <expr>  -- disjunction
             | <expr> && <expr>  -- conjunction
             | <expr> ? <expr> : <expr>  -- ternary operator
             | ! <expr>          -- negation
             | ( <expr )
             | <timeprop> <numop> <dur>
             | <numprop> <numop> <num>
             | <strprop> <strop> <str>
             | <typetest>
             | <modetest>
             | prune             -- do not traverse into subdirectories
             | print             -- always true value
             | skip              -- always false value
             | color <num>       -- always true value, override 256-color

<timeprop> ::= atime | ctime | mtime

<numprop>  ::= depth | dev | entries | gid | inode
             | links | mode | rdev | size | total | uid

<numop>    ::= <= | < | >= | > | == | = | !=

<dur>      ::= "./path"          -- mtime of relative path
             | "/path"           -- mtime of absolute path
             | "YYYY-MM-DD HH:MM:SS"
             | "YYYY-MM-DD"      -- at midnight
             | "HH:MM:SS"        -- today
             | "HH:MM"           -- today
             | "-[0-9]+d"        -- n days ago at midnight
             | "-[0-9]+h"        -- n hours before now
             | "-[0-9]+m"        -- n minutes before now
             | "-[0-9]+s"        -- n seconds before now
             | [0-9]+            -- absolute epoch time

<num>      ::= [0-9]+ ( c        -- *1
                      | b        -- *512
                      | k        -- *1024
                      | M        -- *1024*1024
                      | G        -- *1024*1024*1024
                      | T )?     -- *1024*1024*1024*1024

<strprop>  ::= fstype | group | name | path | target | user | xattr

<strop>    ::= == | = | !=       -- string (in)equality
             | ===    | !===     -- case insensitive string (in)equality
             | ~~     | !~~      -- glob (fnmatch)
             | ~~~    | !~~~     -- case insensitive glob (fnmatch)
             | =~     | !=~ | !~ -- POSIX Extended Regular Expressions
             | =~~    | !=~~     -- case insensitive POSIX Extended Regular Expressions

<str>      ::= " ([^"] | "")+ "  -- use "" for a single " inside "
             | $[A-Za-z0-9_]+    -- environment variable

<typetest> ::= type ( == | = | != ) ( b | c | d | p | f | l )

<modetest> ::= mode ( == | =     -- exact permissions
                    | &          -- check if all bits of <octal> set
                    | |          -- check if any bit of <octal> set
                    ) <octal>
             | mode = "<chmod>"  -- check if symbolic mode is satisfied

<octal> ::= [0-7]+

<chmod> ::= <clause> (, <clause>)+

<clause> ::= [guoa]* [+-=] [rwxXstugo]*  -- see chmod(1)
.Ed
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
.Xr du 1 ,
.Xr find 1 ,
.Xr ls 1 ,
.Xr stat 1 ,
.Xr tw 1
.Sh AUTHORS
.An Leah Neukirchen Aq Mt leah@vuxu.org
.Sh LICENSE
.Nm
is licensed under the terms of the MIT license.