Linux ls 命令

来源:互联网 发布:现在淘宝卖什么好 编辑:程序博客网 时间:2024/06/05 23:56

ls
tips:
虽然在终端是每行有多个名称,但是输出的时候是按行输出

语法

ls [OPTION]… [FILE]…

参数

参数 描述 -a, –all 不乎略素有的隐藏文件 -A, –almost-all do not list implied . and .. –author 使用-l列出文件的作者 -b, –escape print C-style escapes for nongraphic characters –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 不列出名称以~结尾的文件 -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 ‘always’ (default if omitted),’auto’, or ‘never’; 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 */=>@ –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/or -s, print human readable sizes (e.g., 1K 234M 2G) –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 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 打印索引 -I, –ignore=PATTERN do not list implied entries matching shell PATTERN -k, –kibibytes default to 1024-byte blocks for disk usage -l 使用长列表格式 -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 raw entry names (don’t treat e.g. control characters spe‐cially) -o 类似于-l,但是不罗列组信息 -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 -r, –reverse reverse order while sorting -R, –recursive list subdirectories recursively -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) –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 (newest first) –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 FORMAT1FORMAT2, then FORMAT1 applies to non-recent files and FORMAT2 to recent files; if STYLE is pre‐ fixed 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, 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 -1 list one file per line. Avoid ‘\n’ with -q or -b

测试:
在文件夹中新建两个文件”a.txt”,”b.txt”和一个文件夹”.a”

claroja@ubuntu:~/test$ tree -a ~/test/home/claroja/test├── .a├── a.txt└── b.txt1 directory, 2 files

ls

claroja@ubuntu:~/test$ lsa.txt  b.txt

ls -a

claroja@ubuntu:~/test$ ls -a.  ..  .a  a.txt  b.txt

ls -A

claroja@ubuntu:~/test$ ls -A.a  a.txt  b.txt

ls -author

claroja@ubuntu:~/test$ ls -authortotal 12K-rw-rw-r--  1 claroja    0 629 17:37 a.txt-rw-rw-r--  1 claroja    0 629 17:38 b.txtdrwxrwxr-x  3 claroja 4.0K 629 17:39 .drwxrwxr-x  2 claroja 4.0K 629 17:40 .adrwxr-xr-x 38 claroja 4.0K 629 17:40 ..

ls -b

不知道什么意思

ls -B

不输出以~结尾的文件

ls -ltc -lc -c

claroja@ubuntu:~/test$ ls -ltc #按时间排序显示详细信息,倒序total 0-rw-rw-r-- 1 claroja claroja 0 629 17:38 b.txt-rw-rw-r-- 1 claroja claroja 0 629 17:37 a.txtclaroja@ubuntu:~/test$ ls -lc #按名称排序显示详细信息,升序total 0-rw-rw-r-- 1 claroja claroja 0 629 17:37 a.txt-rw-rw-r-- 1 claroja claroja 0 629 17:38 b.txtclaroja@ubuntu:~/test$ ls -c #按时间排序,倒序b.txt  a.txt

ls -C

未知

ls -d

claroja@ubuntu:~/test$ ls -d #列出目录.

ls -D

未知

ls -f

未知

ls -F

未知

ls -f

不排序,这样会减少命令的时间

ls -g

claroja@ubuntu:~/test$ ls -g # 不列出所有者total 0-rw-rw-r-- 1 claroja 0 629 17:37 a.txt-rw-rw-r-- 1 claroja 0 629 17:38 b.txt

ls -G

未知

ls -lh

使得大小显示符合人的阅读习惯

ls -H

未知

ls -i

claroja@ubuntu:~/test$ ls -i #列出文章id5382202 a.txt  5382204 b.txt

ls -I

未知

ls -k

未知

ls -l

claroja@ubuntu:~/test$ ls -ltotal 0-rw-rw-r-- 1 claroja claroja 0 629 17:37 a.txt-rw-rw-r-- 1 claroja claroja 0 629 17:38 b.txt

ls -L

未知

原创粉丝点击