Linux命令之ls 简述


What?

列出目录的内容

How?

ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file ...]

Points——常用的参数

ls -l 显示目录文件的详细信息[linux文件的属性]

ls -t 按修改时间逆序排列

ls -r reverse 按相反顺序排列

ls -F 标识文件的类型 /表示目录  *表示可执行文件  @表示软连接  =表示socket文件  |表示管道文件  这些标识符跟在文件名后面

Example

显示该目录下文件详细信息,按修改时间逆序排列(最新修改的在最下面)

➜  test  ls -lrtF
total 8
drwxr-xr-x  2 a2014  staff  68  1 20 18:07 movies/
drwxr-xr-x  2 a2014  staff  68  1 20 18:07 music/
drwxr-xr-x  2 a2014  staff  68  1 20 18:07 download/
drwxr-xr-x  2 a2014  staff  68  1 20 18:08 documents/
drwxr-xr-x  2 a2014  staff  68  1 20 18:08 pictures/
-rw-r--r--  1 a2014  staff  2  1 20 18:27 test.txt
-rw-r--r--  1 a2014  staff  0  1 20 18:28 test1.txt

total——该目录下文件和目录的大小,单位KB

其余详见下面的Linux文件的详细属性

total 0
drwxr-xr-x  2 a2014  staff  68  1 20 18:08 documents
drwxr-xr-x  2 a2014  staff  68  1 20 18:07 download
drwxr-xr-x  2 a2014  staff  68  1 20 18:07 movies
drwxr-xr-x  2 a2014  staff  68  1 20 18:07 music
drwxr-xr-x  2 a2014  staff  68  1 20 18:08 pictures
-rw-r--r--  1 a2014  staff  0  1 20 18:08 test.txt

total——该目录下文件和目录的大小,单位KB

第一字段共有10个字符,第一个字符表示文件的类型,d表示路径,-表示普通文件;剩下的9个字符每3个一组表示

Linux下ls命令的实现 

本文永久更新链接地址:

相关内容