Update ls.md
This commit is contained in:
parent
2819aeb6c0
commit
4b7010d9f4
242
command/ls.md
242
command/ls.md
|
|
@ -10,110 +10,158 @@ ls
|
|||
### 语法
|
||||
|
||||
```shell
|
||||
ls(选项)(参数)
|
||||
ls [选项] [文件名...]
|
||||
```
|
||||
|
||||
### 选项
|
||||
|
||||
```shell
|
||||
-a, --all # 不隐藏任何以. 开始的项目
|
||||
-A, --almost-all # 列出除. 及.. 以外的任何项目
|
||||
--author # 与-l 同时使用时列出每个文件的作者
|
||||
-b, --escape # 以八进制溢出序列表示不可打印的字符
|
||||
--block-size=SIZE # scale sizes by SIZE before printing them; e.g.,
|
||||
# '--block-size=M' prints sizes in units of
|
||||
# 1,048,576 bytes; 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
|
||||
# modification of file status information);
|
||||
# with -l: show ctime and sort by name;
|
||||
# otherwise: sort by ctime, newest first
|
||||
-C # list entries by columns
|
||||
--color[=WHEN] # colorize the output; WHEN can be 'never', 'auto',
|
||||
# or 'always' (the default); more info below
|
||||
-d, --directory # list directories themselves, not their contents
|
||||
-D, --dired # generate output designed for Emacs' dired mode
|
||||
-f # do not sort, enable -aU, disable -ls --color
|
||||
-F, --classify # append indicator (one of */=>@|) to entries
|
||||
--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 # 类似-l,但不列出所有者
|
||||
--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 # 以一个长列表的形式,不输出组名
|
||||
-h, --human-readable # 与-l 一起,以易于阅读的格式输出文件大小
|
||||
(例如 1K 234M 2G)
|
||||
--si # 同上面类似,但是使用1000 为基底而非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 directory
|
||||
--hide=PATTERN # do not list implied entries matching shell PATTERN
|
||||
# (overridden by -a or -A)
|
||||
--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 disk usage
|
||||
-l # 使用较长格式列出信息
|
||||
-L, --dereference # 当显示符号链接的文件信息时,显示符号链接所指示
|
||||
# 的对象而并非符号链接本身的信息
|
||||
-m # 所有项目以逗号分隔,并填满整行行宽
|
||||
-n, --numeric-uid-gid # 类似 -l,但列出UID 及GID 号
|
||||
-N, --literal # 输出未经处理的项目名称 (如不特别处理控制字符)
|
||||
-o # 类似 -l,但不列出有关组的信息
|
||||
-p, --indicator-style=slash # 对目录加上表示符号"/"
|
||||
-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, c, escape
|
||||
-r, --reverse # 逆序排列
|
||||
-R, --recursive # 递归显示子目录
|
||||
-s, --size # 以块数形式显示每个文件分配的尺寸
|
||||
-S # sort by file size
|
||||
--sort=WORD # sort by WORD instead of name: none (-U), size (-S),
|
||||
# time (-t), version (-v), extension (-X)
|
||||
--time=WORD # with -l, show time as WORD instead of default
|
||||
# modification time: atime or access or use (-u)
|
||||
# ctime or status (-c); also use specified time
|
||||
# as sort key if --sort=time
|
||||
--time-style=STYLE # with -l, show times using style STYLE:
|
||||
# full-iso, long-iso, iso, locale, or +FORMAT;
|
||||
# FORMAT is interpreted like in 'date'; if FORMAT
|
||||
# is FORMAT1<newline>FORMAT2, then FORMAT1 applies
|
||||
# to non-recent files and FORMAT2 to recent files;
|
||||
# if STYLE is prefixed with 'posix-', STYLE
|
||||
# takes effect only outside the POSIX locale
|
||||
-t # sort by modification time, newest first
|
||||
-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
|
||||
-U # do not sort; list entries in directory order
|
||||
-v # natural sort of (version) numbers within text
|
||||
-w, --width=COLS # assume screen width instead of current value
|
||||
-x # list entries by lines instead of by columns
|
||||
-X # sort alphabetically by entry extension
|
||||
-1 # list one file per line
|
||||
-C # 多列输出,纵向排序。
|
||||
-F # 每个目录名加 "/" 后缀,每个 FIFO 名加 "|" 后缀, 每个可运行名加“ * ”后缀。
|
||||
-R # 递归列出遇到的子目录。
|
||||
-a # 列出所有文件,包括以 "." 开头的隐含文件。
|
||||
-c # 使用“状态改变时间”代替“文件修改时间”为依据来排序(使用“-t”选项时)或列出(使用“-l”选项时)。
|
||||
-d # 将目录名象其它文件一样列出,而不是列出它们的内容。
|
||||
-i # 输出文件前先输出文件系列号(即 i 节点号: i-node number)。 -l 列出(以单列格式)文件模式(file mode),文件的链 接数,所有者名,组名,文件大小(以字节为单位),时间信息,及文件名。缺省时,时间信息显示最近修改时间;可以以选项“-c”和“-u”选择显示其它两种时间信息。对于设 备文件,原先显示文件大小的区域通常显示的是主要和次要的号(majorand minor device numbers)。
|
||||
-q # 将文件名中的非打印字符输出为问号。(对于到终端的输出这是缺省的。)
|
||||
-r # 逆序排列。
|
||||
-t # 按时间信息排序。
|
||||
-u # 使用最近访问时间代替最近修改时间为依据来排序(使用“-t”选项时)或列出(使用“-l”选项时)。
|
||||
-1 # 单列输出。
|
||||
-1, --format=single-column # 一行输出一个文件(单列输出)。如标准输出不是到终端,此选项就是缺省选项。
|
||||
-a, --all # 列出目录中所有文件,包括以“.”开头的文件。
|
||||
-b, --escape # 把文件名中不可输出的字符用反斜杠加字符编号(就象在 C 语言里一样)的形式列出。
|
||||
-c, --time=ctime, --time=status
|
||||
# 按文件状态改变时间(i节点中的ctime)排序并输出目录内
|
||||
# 容。如采用长格式输出(选项“-l”),使用文件的状态改
|
||||
# 变时间取代文件修改时间。【译注:所谓文件状态改变(i节
|
||||
# 点中以ctime标志),既包括文件被修改,又包括文件属性( 如所有者、组、链接数等等)的变化】
|
||||
-d, --directory
|
||||
# 将目录名象其它文件一样列出,而不是列出它们的内容。
|
||||
-f # 不排序目录内容;按它们在磁盘上存储的顺序列出。同时启 动“ -a ”选项,如果在“ -f ”之前存在“ -l
|
||||
# ”、“ - -color ”或“ -s ”,则禁止它们。
|
||||
-g # 忽略,为兼容UNIX用。
|
||||
-i, --inode
|
||||
# 在每个文件左边打印 i 节点号(也叫文件序列号和索引号: file serial number and index num‐
|
||||
# ber)。i节点号在每个特定的文件系统中是唯一的。
|
||||
-k, --kilobytes
|
||||
# 如列出文件大小,则以千字节KB为单位。
|
||||
-l, --format=long, --format=verbose
|
||||
# 除每个文件名外,增加显示文件类型、权限、硬链接数、所 有者名、组名、大小( byte
|
||||
# )、及时间信息(如未指明是 其它时间即指修改时间)。对于6个月以上的文件或超出未来 1
|
||||
# 小时的文件,时间信息中的时分将被年代取代。
|
||||
# 每个目录列出前,有一行“总块数”显示目录下全部文件所 占的磁盘空间。块默认是 1024
|
||||
# 字节;如果设置了 POSIXLY_CORRECT 的环境变量,除非用“ -k ”选项,则默认块大小是 512 字
|
||||
# 节。每一个硬链接都计入总块数(因此可能重复计数),这无 疑是个缺点。
|
||||
|
||||
SELinux options:
|
||||
# 列出的权限类似于以符号表示(文件)模式的规范。但是 ls
|
||||
# 在每套权限的第三个字符中结合了多位( multiple bits ) 的信息,如下: s 如果设置了 setuid
|
||||
# 位或 setgid 位,而且也设置了相应的可执行位。 S 如果设置了 setuid 位或 setgid
|
||||
# 位,但是没有设置相应的可执行位。 t 如果设置了 sticky 位,而且也设置了相应的可执行位。 T
|
||||
# 如果设置了 sticky 位,但是没有设置相应的可执行位。 x
|
||||
# 如果仅仅设置了可执行位而非以上四种情况。 - 其它情况(即可执行位未设置)。
|
||||
-m, --format=commas
|
||||
# 水平列出文件,每行尽可能多,相互用逗号和一个空格分隔。
|
||||
-n, --numeric-uid-gid
|
||||
# 列出数字化的 UID 和 GID 而不是用户名和组名。
|
||||
-o # 以长格式列出目录内容,但是不显示组信息。等于使用“ --format=long --no-group
|
||||
# ”选项。提供此选项是为了与其它版本的 ls 兼容。
|
||||
-p # 在每个文件名后附上一个字符以说明该文件的类型。类似“ -F ”选项但是不 标示可执行文件。
|
||||
-q, --hide-control-chars
|
||||
# 用问号代替文件名中非打印的字符。这是缺省选项。
|
||||
-r, --reverse
|
||||
# 逆序排列目录内容。
|
||||
-s, --size
|
||||
# 在每个文件名左侧输出该文件的大小,以 1024 字节的块为单位。如果设置了 POSIXLY_CORRECT
|
||||
# 的环境变量,除非用“ -k ”选项,块大小是 512 字节。
|
||||
-t, --sort=time
|
||||
# 按文件最近修改时间( i 节点中的 mtime )而不是按文件名字典序排序,新文件 靠前。
|
||||
-u, --time=atime, --time=access, --time=use
|
||||
# 类似选项“ -t ”,但是用文件最近访问时间( i 节点中的 atime )取代文件修
|
||||
# 改时间。如果使用长格式列出,打印的时间是最近访问时间。
|
||||
-w, --width cols
|
||||
# 假定屏幕宽度是 cols ( cols 以实际数字取代)列。如未用此选项,缺省值是这
|
||||
# 样获得的:如可能先尝试取自终端驱动,否则尝试取自环境变量 COLUMNS (如果设
|
||||
# 置了的话),都不行则取 80 。
|
||||
|
||||
--lcontext # Display security context. Enable -l. Lines
|
||||
# will probably be too wide for most displays.
|
||||
-Z, --context # Display security context so it fits on most
|
||||
# displays. Displays only mode, user, group,
|
||||
# security context and file name.
|
||||
--scontext # Display only security context and file name.
|
||||
--help # 显示此帮助信息并退出
|
||||
--version # 显示版本信息并退出
|
||||
-x, --format=across, --format=horizontal
|
||||
# 多列输出,横向排序。
|
||||
|
||||
-A, --almost-all
|
||||
# 显示除 "." 和 ".." 外的所有文件。
|
||||
|
||||
-B, --ignore-backups
|
||||
# 不输出以“ ~ ”结尾的备份文件,除非已经在命令行中给出。
|
||||
|
||||
-C, --format=vertical
|
||||
# 多列输出,纵向排序。当标准输出是终端时这是缺省项。使用命令名 dir 和 d 时, 则总是缺省的。
|
||||
|
||||
-D, --dired
|
||||
# 当采用长格式(“-l”选项)输出时,在主要输出后,额外打印一行: //DIRED// BEG1 END1 BEG2
|
||||
# END2 ...
|
||||
|
||||
# BEGn 和 ENDn 是无符号整数,记录每个文件名的起始、结束位置在输出中的位置(
|
||||
# 字节偏移量)。这使得 Emacs 易于找到文件名,即使文件名包含空格或换行等非正
|
||||
# 常字符也无需特异的搜索。
|
||||
#
|
||||
# 如果目录是递归列出的(“ -R ”选项),每个子目录后列出类似一行:
|
||||
# //SUBDIRED// BEG1 END1 ... 【译注:我测试了 TurboLinux4.0 和 RedHat6.1 ,发现它们都是在 “
|
||||
# //DIRED// BEG1... ”之后列出“ //SUBDIRED// BEG1 ... ”,也即只有一个
|
||||
# 而不是在每个子目录后都有。而且“ //SUBDIRED// BEG1 ... ”列出的是各个子目 录名的偏移。】
|
||||
|
||||
-F, --classify, --file-type
|
||||
# 在每个文件名后附上一个字符以说明该文件的类型。“ * ”表示普通的可执行文件; “ / ”表示目录;“
|
||||
# @ ”表示符号链接;“ | ”表示FIFOs;“ = ”表示套接字 (sockets) ;什么也没有则表示普通文件。
|
||||
|
||||
-G, --no-group
|
||||
# 以长格式列目录时不显示组信息。
|
||||
|
||||
-I, --ignorepattern
|
||||
# 除非在命令行中给定,不要列出匹配shell文件名匹配式(pattern ,不是指一般
|
||||
# 表达式)的文件。在shell中,文件名以"."起始的不与在文件名匹配式(pattern)
|
||||
# 开头的通配符匹配。
|
||||
|
||||
-L, --dereference
|
||||
# 列出符号链接指向的文件的信息,而不是符号链接本身。
|
||||
|
||||
-N, --literal
|
||||
# 不要用引号引起文件名。
|
||||
|
||||
-Q, --quote-name
|
||||
# 用双引号引起文件名,非打印字符以 C 语言的方法表示。
|
||||
|
||||
-R, --recursive
|
||||
# 递归列出全部目录的内容。
|
||||
|
||||
-S, --sort=size
|
||||
# 按文件大小而不是字典序排序目录内容,大文件靠前。
|
||||
|
||||
-T, --tabsize cols
|
||||
# 假定每个制表符宽度是 cols 。缺省为 8。为求效率, ls 可能在输出中使用制表符。 若 cols 为
|
||||
0,则不使用制表符。
|
||||
|
||||
-U, --sort=none
|
||||
# 不排序目录内容;按它们在磁盘上存储的顺序列出。(选项“-U”和“-f”的不
|
||||
# 同是前者不启动或禁止相关的选项。)这在列很大的目录时特别有用,因为不加排序
|
||||
# 能显著的加快速度。
|
||||
|
||||
-X, --sort=extension
|
||||
# 按文件扩展名(由最后的 "." 之后的字符组成)的字典序排序。没有扩展名的先列 出。
|
||||
|
||||
--color[=when]
|
||||
# 指定是否使用颜色区别文件类别。环境变量 LS_COLORS 指定使用的颜色。如何设置 这个变量见 dir‐
|
||||
# colors(1) 。 when 可以被省略,或是以下几项之一:
|
||||
none # 不使用颜色,这是缺省项。
|
||||
# auto 仅当标准输出是终端时使用。 always 总是使用颜色。指定 --color 而且省略 when 时就等同于
|
||||
# --color=always 。
|
||||
|
||||
--full-time
|
||||
# 列出完整的时间,而不是使用标准的缩写。格式如同 date(1) 的缺省格式;此格式
|
||||
# 是不能改变的,但是你可以用 cut(1) 取出其中的日期字串并将结果送至命令 “ date -d ”。
|
||||
|
||||
# 输出的时间包括秒是非常有用的。( Unix 文件系统储存文件的时间信息精确到秒,
|
||||
# 因此这个选项已经给出了系统所知的全部信息。)例如,当你有一个 Makefile 文件
|
||||
# 不能恰当的生成文件时,这个选项会提供帮助。
|
||||
```
|
||||
|
||||
### 参数
|
||||
|
|
|
|||
Loading…
Reference in New Issue