Documentation
¶
Overview ¶
Package ls implements the ls builtin command.
ls — list directory contents
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default). Sort entries alphabetically by default.
Accepted flags:
-1
List one file per line. This is the default when output is not a
terminal (which is always the case in this shell).
-a, --all
Do not ignore entries starting with . (includes . and ..).
-A, --almost-all
Do not ignore entries starting with . but omit . and ..
-d, --directory
List directories themselves, not their contents.
-r, --reverse
Reverse order while sorting.
-S
Sort by file size, largest first.
-t
Sort by modification time, newest first.
-F, --classify
Append indicator (one of * / = @ |) to entries.
-p
Append / indicator to directories.
-R, --recursive
List subdirectories recursively.
-l
Use a long listing format: mode, hard links, owner, group, size, date, name.
-h, --human-readable
With -l, print sizes in human-readable format (e.g. 1K, 234M).
--offset N (non-standard)
Skip the first N raw directory entries before collecting results.
NOTE: offset operates on filesystem order, not sorted order —
entries are sorted only within each page. For predictable
pagination of large directories, use consistent offset/limit
pairs. Applies to single-directory listings only; silently
ignored with -R or multiple arguments.
--limit N (non-standard)
Show at most N entries, capped at MaxDirEntries (1,000) per call.
Applies to single-directory listings only; silently ignored with -R
or multiple arguments.
When a directory exceeds MaxDirEntries (1,000) and no explicit --offset/ --limit is given, ls prints the first 1,000 entries, emits a warning to stderr, and exits 1. Use --offset/--limit to paginate through larger directories.
Exit codes:
0 All entries listed successfully. 1 At least one error occurred (missing file, permission denied, etc.). 1 Directory truncated (exceeded MaxDirEntries without --offset/--limit). 1 Invalid usage (unrecognised flag, etc.).
Index ¶
Constants ¶
View Source
const MaxDirEntries = 1_000
MaxDirEntries is the maximum number of entries ls will process per directory.
Variables ¶
View Source
var Cmd = builtins.Command{
Name: "ls",
Description: "list directory contents",
MakeFlags: registerFlags,
}
Cmd is the ls builtin command descriptor.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.