aboutsummaryrefslogblamecommitdiff
path: root/lr.1
blob: 5082a8e46f5bfcb19e001beccf6c88e37ea99368 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                    






                           

                                                                       
               
               
                 
                             
   
                 
                
                                            





                                                               





                                                             


           
           




                                    







                     
   









                                                               


                           

                                                      



                                        




                                     





                                                       



                               


        






                          
                        
        




                                                    





                                    
        



                                    

                    



                            



       
        



                         



                  



       













                    







                                                        


                               







                                                    


                             



      


                



       




                 

                                              




                                       
                       
     

     
                              

                              





                                                      
                                        
                          
                   
                                             
                   
                                            

           
     











                                   


               

                           


                





                                         

        

     

       






                                              




                          
           




                     













                                                       


             








           
                                
           




                                                

                                          

           
                      




                                     
                                        





























                                                         
                            

     

      
      
   




                                                    


                       





                                               
                                                            








                                                                       
                                                      
                                                                         





                                                       
                                            



















                                                          
                                                                   
 





                                                                                       

                                                                  
                                                        
 
                                                             
 
                                                     


                                                                    
                                                                       

                  



                                                        






               

            
           
                                       


                                               
.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 W | 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, print during traversal.
.It Fl W
Sort results by name and print during traversal.
.Po
This is subtly different from sorting by file name with
.Fl on
as it prints directories directly before their contents.
.Pc
.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.