LR(1)
π LR(1) π β the lr manual page, bestie
okay so, welcome to LR(1), straight outta the General Commands Manual (section 1, you know the one). this page is about lr and it's genuinely one of the good ones. no cap. π¦
β¨ NAME β¨
lr β list files, recursively. that's the whole thing. short, sweet, iconic. π
β¨ SYNOPSIS β¨
lr [-0 | -F | -l [-TA | -TC | -TM] | -S | -f fmt]
[-B | -D] [-H | -L] [-1AGPQXdhsx] [-U | -W | -o ord]
[-e regex] [-t test] [-C [color:]path] path ...
β¨ DESCRIPTION β¨
lr is a versatile tool for generating file listings, and the way it lets you configure the formatting, the ordering and the filtering? obsessed. genuinely.
so like, if you don't hand it a path, or the path you hand it is an empty string, it just uses the current directory. default behavior, love that for you. πΈ
and here's a cute lil trick: the special path argument - makes lr read file names from standard input instead of traversing path. and the special path argument @file makes lr read file names from file. iykyk. β¨
traversal order, let's talk about it. by default, lr traverses directories before their entries. when -D is used, the subdirectories (and files) get traversed first. and when -B is used, each level of depth is traversed before moving deeper. main character traversal energy, honestly. π
the options are as follows:
-0β output filenames separated by NUL bytes. and likewise, read input filenames separated by NUL bytes. NUL both ways, periodt.-1β don't go below one level of directories. stay shallow, stay cute.-Aβ don't list files starting with a dot. bye hidden files, you're not invited π«Ά-Bβ use breadth first traversal. for each depth of the directory tree, files are sorted and printed, then the next depth is looked at. level by level, slay.-C[color:]pathβ behaves as if path was passed like an ordinary argument, but overrides the color of the file names to the number color, which must be between 0 and 255 (default: 2, green). implies-GG. π-Dβ use depth first traversal. lowkey important warning:prunewill not work with this, butentriesandtotalare computed on the fly. so like, pick your fighter. π-Fβ output filenames and an indicator of their file type (one of*/=>@|).-Gβ colorize output to TTY. use it twice to force colorized output. and if the environment variableNO_COLORis set, colors are never used. never ever. respect the boundary. π«π-Hβ only follow symlinks on command line (default: don't follow symlinks).-Lβ follow all symlinks. all of them. chasing every link fr fr.-Pβ quote file names using Austin Group #249 syntax$'...'(implies-Q).-Qβ quote file names (this is the default for output to TTY).-Sβ output inspired by BSDstat(1)(implies-Q).-TAβ with-l, print atime.-TCβ with-l, print ctime.-TMβ with-l, print mtime. this is the default, so like, the main character of the three.-Uβ don't sort results, print during traversal. chaotic. love it.-Wβ sort results by name and print during traversal. and listen, this is subtly different from sorting by file name with-on, because it prints directories directly before their contents. subtle but real. π-Xβ output OSC 8 hyperlinks to TTY. use it twice to force hyperlinks.-dβ don't enter directories. we're staying outside, respectfully.-eregexβ only show files where the basename matches the POSIX ERE regex.-ffmtβ custom formatting, go read the FORMATTING section below bestie.-hβ print human readable size for-l(also applies to%s).-lβ long output Γ lals -l(implies-Q).-oordβ sort according to ord, see SORT ORDER.-sβ strip the directory prefix passed on the command line.-ttestβ only show files matching the expression test, see TESTS. and heads up: multiple occurrences of-tand-eare regarded as a conjunction. they all gotta agree. π€-xβ don't enter other filesystems. we stay on our own turf.
β¨ FORMATTING β¨
lr format strings support the following escape sequences:
\a,\b,\f,\n,\r,\vβ special characters, same as in C\dddβ byte with one, two or three-digit octal value\xddβ byte with one or two-digit hexadecimal value%%β a plain%%sβ file size in bytes%Sβ file size, with human readable unit%bβ file size in 512-byte blocks%kβ file size in 1024-byte blocks%dβ path depth%Dβ device number (stat.st_dev)%Rβ device ID for special files (stat.st_rdev)%iβ inode number%Iβ one space character for every depth level%pβ full path (%Pif-sis used)%Pβ full path without command line argument prefix%lβ symlink target%nβ number of hardlinks%Fβ file indicator type symbol (one of*/=>@|)%fβ file basename (everything after last/)%A-,%C-,%T-β relative age for atime/ctime/mtime.%Ax,%Cx,%Txβ result ofstrftime(3)for%xon atime/ctime/mtime%mβ octal file permissions%Mβls-style symbolic file permissions%yβls-style symbolic file type (bcdfls)%gβ group name%Gβ numeric gid%uβ user name%Uβ numeric uid%eβ number of entries in directories%tβ total size used by accepted files in directories (only with-D)%Yβ type of the filesystem the file resides on%xβ Linux-only: print a combination of#for files with security capabilities,+for files with an ACL,@for files with other extended attributes
β¨ SORT ORDER β¨
the sort order is a string consisting of the following letters. and here's the tea: uppercase letters reverse the sorting. default sort order is n. π
aβ atimecβ ctimedβ path deptheβ file extensioniβ inode numbermβ mtimenβ file namepβ directory namesβ file sizetβ file type. this sorts all directories before other files.vβ file name as version numbers (sorts2before10) β so like, numerically correct, finally.
e.g. Sn sorts first by size, smallest last, and then by name (in case sizes are equal). see? cute and logical. β¨
β¨ TESTS β¨
lr tests are given by the following EBNF:
<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)
β¨ EXIT STATUS β¨
the lr utility exits 0 on success, and >0 if an error occurs. simple. clean. honest. π
β¨ SEE ALSO β¨
du(1), find(1), ls(1), stat(1), tw(1) β go read those too, they're the friend group. π«Ά
β¨ AUTHORS β¨
Leah Neukirchen <leah@vuxu.org> β the icon, the legend, the moment. π
β¨ LICENSE β¨
lr is licensed under the terms of the MIT license. slay. π
and that's the page bestie!! this was the lr page, LR(1), from Debian, dated December 5, 2019 β go list some files recursively and have the best day ever πβ¨π
π¦ where this page comes from
- debian bookworm: lr 1.5.1-3 Β· MIT
- debian trixie: lr 1.5.1-3 Β· MIT
- ubuntu jammy: lr 1.5.1-3 Β· MIT
- ubuntu noble: lr 1.5.1-3 Β· MIT
- ubuntu resolute: lr 1.5.1-3build1 Β· MIT
- ubuntu stonking: lr 1.5.1-3build1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms