dir [OPTION]... [FILE]...
!subtitle:功能
列出目录内容。
和 ls 命令基本等价,区别在于默认使用 -C 和 -b 选项。
!subtitle:类型
可执行文件(/usr/bin/dir),属于 coreutils。
!subtitle:参数
OPTION 选项:
-a, --all - 显示隐藏文件(文件名以 . 开头)
-A, --almost-all - 显示隐藏文件,但不显示 . 和 ..
--author - 显示文件的作者;和 -l 选项一起使用
--block-size=SIZE - 文件大小的单位;和 -l 选项一起使用
-B, --ignore-backups 不显示备份文件(文件名以 ~ 结束)
-c - 按 ctime(文件状态信息最后更新的时间)排序;和 -lt 选项一起使用
-C - 竖向排列
--color[=WHEN] - 何时使用彩色,有效值:always,auto,never
-d, --directory - 查看目录本身,而不是目录的内容
-D, --dired - 生成为 Emacs 的 dired 模式设计的输出
-f - 显示所有文件且不进行排序(按照目录顺序显示)
-F, --classify[=WHEN] - 何时添加 文件类型指示器),有效值:always,auto,never
--file-type - 显示文件类型指示器;同 --classify 但是不添加 *
--format=WORD - 格式,有效值:across,commas,horizontal,long,single-column,verbose,vertical
--full-time - 显示完整的时间;同 -l --time-style=full-iso
-g - 显示文件详情;同 -l 但不显示所有者
--group-directories-first - 分组时将目录排在文件前面
-G, --no-group - 不显示分组名
-h, --human-readable - 让详细信息更适合人类阅读;和 -l 或 -s 选择一起使用
--si - 让详细信息更适合人类阅读;同 -h 但是文件大小以 1000 为单位,而不是 1024
-H, --dereference-command-line - 参数是符号链接时,查看源文件
--dereference-command-line-symlink-to-dir - 参数是目录的符号链接时,查看源目录
--hide=PATTERN - 隐藏匹配的文件
--hyperlink[=WHEN] - 何时将文件名显示为超链接(现代终端上点击可以打开文件管理器),有效值:always,auto,never
--indicator-style=WORD - 添加 文件类型指示器) ,有效值:none,slash,file-type,classify
-i, --inode - 显示文件的 inode 编号
-I, --ignore=PATTERN - 不显示匹配的文件
-k, --kibibytes - 文件大小以 1024 字节为单位
-l - 显示详细信息
-L, --dereference - 符号链接显示源文件的信息,而非符号链接本身的信息
-m - 用逗号分隔条目
-n, --numeric-uid-gid - 显示详细信息,但是所有者和所属组显示为 ID 而非名称
-N, --literal - 含特殊字符的文件名不添加单引号
-o - 显示详细信息,但不显示所属组信息
-p, --indicator-style=slash - 添加 / 指示器
-q, --hide-control-chars - 非 图形字符 显示为 ?
--show-control-chars - 直接显示非 图形字符
-Q, --quote-name - 用双引号包裹文件名
--quoting-style=WORD - 引号风格,有效值:literal, locale, shell, shell-always, shell-escape, shell-escape-always, c, escape
-r, --reverse - 逆序
-R, --recursive - 递归查看子目录
-s, --size - 显示文件分配的块数
-S - 按文件大小排序,最大的优先
--sort=WORD - 排序规则,有效值:none, size, time, version, extension, width
--time=WORD - 显示或排序的时间,有效值:atime, ctime, mtime, btime
--time-style=TIME_STYLE - 日期和时间的格式
-t - 按时间排序
-T, --tabsize=COLS - 制表符的宽度
-u - 显示 atime 或按 atime 排序
-U - 不排序
-v - 自然排序
-w, --width=COLS - 一行的宽度,0 表示无限
-x - 横向排列
-X - 按扩展名排序
-Z, --context - 显示安全上下文
--zero - 以空字符(\0)作为行的结尾,而不是换行符(\n)
-1 - 每行只显示一个文件
--help - 显示帮助
--version - 显示版本
FILE - 文件列表
DIR(1) User Commands DIR(1)
NAME
dir - list directory contents
SYNOPSIS
dir [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is speci‐
fied.
Mandatory arguments to long options are mandatory for short options
too.
-a, --all
do not ignore entries starting with .
-A, --almost-all
do not list implied . and ..
--author
with -l, print the author of each file
-b, --escape
print C-style escapes for nongraphic characters
--block-size=SIZE
with -l, scale sizes by SIZE when printing them; e.g.,
'--block-size=M'; see SIZE format below
-B, --ignore-backups
do not list implied entries ending with ~
-c with -lt: sort by, and show, ctime (time of last change of file
status information); with -l: show ctime and sort by name; oth‐
erwise: sort by ctime, newest first
-C list entries by columns
--color[=WHEN]
color the output WHEN; more info below
-d, --directory
list directories themselves, not their contents
-D, --dired
generate output designed for Emacs' dired mode
-f list all entries in directory order
-F, --classify[=WHEN]
append indicator (one of */=>@|) to entries WHEN
--file-type
likewise, except do not append '*'
--format=WORD
across -x, commas -m, horizontal -x, long -l, single-column -1,
verbose -l, vertical -C
--full-time
like -l --time-style=full-iso
-g like -l, but do not list owner
--group-directories-first
group directories before files; can be augmented with a --sort
option, but any use of --sort=none (-U) disables grouping
-G, --no-group
in a long listing, don't print group names
-h, --human-readable
with -l and -s, print sizes like 1K 234M 2G etc.
--si likewise, but use powers of 1000 not 1024
-H, --dereference-command-line
follow symbolic links listed on the command line
--dereference-command-line-symlink-to-dir
follow each command line symbolic link that points to a direc‐
tory
--hide=PATTERN
do not list implied entries matching shell PATTERN (overridden
by -a or -A)
--hyperlink[=WHEN]
hyperlink file names WHEN
--indicator-style=WORD
append indicator with style WORD to entry names: none (default),
slash (-p), file-type (--file-type), classify (-F)
-i, --inode
print the index number of each file
-I, --ignore=PATTERN
do not list implied entries matching shell PATTERN
-k, --kibibytes
default to 1024-byte blocks for file system usage; used only
with -s and per directory totals
-l use a long listing format
-L, --dereference
when showing file information for a symbolic link, show informa‐
tion for the file the link references rather than for the link
itself
-m fill width with a comma separated list of entries
-n, --numeric-uid-gid
like -l, but list numeric user and group IDs
-N, --literal
print entry names without quoting
-o like -l, but do not list group information
-p, --indicator-style=slash
append / indicator to directories
-q, --hide-control-chars
print ? instead of nongraphic characters
--show-control-chars
show nongraphic characters as-is (the default, unless program is
'ls' and output is a terminal)
-Q, --quote-name
enclose entry names in double quotes
--quoting-style=WORD
use quoting style WORD for entry names: literal, locale, shell,
shell-always, shell-escape, shell-escape-always, c, escape
(overrides QUOTING_STYLE environment variable)
-r, --reverse
reverse order while sorting
-R, --recursive
list subdirectories recursively
-s, --size
print the allocated size of each file, in blocks
-S sort by file size, largest first
--sort=WORD
sort by WORD instead of name: none (-U), size (-S), time (-t),
version (-v), extension (-X), width
--time=WORD
select which timestamp used to display or sort; access time
(-u): atime, access, use; metadata change time (-c): ctime, sta‐
tus; modified time (default): mtime, modification; birth time:
birth, creation;
with -l, WORD determines which time to show; with --sort=time,
sort by WORD (newest first)
--time-style=TIME_STYLE
time/date format with -l; see TIME_STYLE below
-t sort by time, newest first; see --time
-T, --tabsize=COLS
assume tab stops at each COLS instead of 8
-u with -lt: sort by, and show, access time; with -l: show access
time and sort by name; otherwise: sort by access time, newest
first
-U do not sort; list entries in directory order
-v natural sort of (version) numbers within text
-w, --width=COLS
set output width to COLS. 0 means no limit
-x list entries by lines instead of by columns
-X sort alphabetically by entry extension
-Z, --context
print any security context of each file
--zero end each output line with NUL, not newline
-1 list one file per line
--help display this help and exit
--version
output version information and exit
The SIZE argument is an integer and optional unit (example: 10K is
10*1024). Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024) or KB,MB,...
(powers of 1000). Binary prefixes can be used, too: KiB=K, MiB=M, and
so on.
The TIME_STYLE argument can be full-iso, long-iso, iso, locale, or
+FORMAT. FORMAT is interpreted like in date(1). If FORMAT is FOR‐
MAT1<newline>FORMAT2, then FORMAT1 applies to non-recent files and FOR‐
MAT2 to recent files. TIME_STYLE prefixed with 'posix-' takes effect
only outside the POSIX locale. Also the TIME_STYLE environment vari‐
able sets the default style to use.
The WHEN argument defaults to 'always' and can also be 'auto' or
'never'.
Using color to distinguish file types is disabled both by default and
with --color=never. With --color=auto, ls emits color codes only when
standard output is connected to a terminal. The LS_COLORS environment
variable can change the settings. Use the dircolors(1) command to set
it.
Exit status:
0 if OK,
1 if minor problems (e.g., cannot access subdirectory),
2 if serious trouble (e.g., cannot access command-line argument).
AUTHOR
Written by Richard M. Stallman and David MacKenzie.
REPORTING BUGS
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
COPYRIGHT
Copyright © 2023 Free Software Foundation, Inc. License GPLv3+: GNU
GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
Full documentation <https://www.gnu.org/software/coreutils/dir>
or available locally via: info '(coreutils) dir invocation'
GNU coreutils 9.4 April 2024 DIR(1)