linux命令六ls

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/uotail/article/details/88108613

NAME

   ls - list directory contents

SYNOPSIS

   ls [OPTION]... [FILE]...

DESCRIPTION

  List information about the FILEs (the current directory by default).  Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
       列出关于文件的信息(默认情况下是当前目录)。如果没有指定则按字母顺序对条目排序。

       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 ..
              不要列出隐含的.和 . .

       -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
              用-lt:按ctime(上次修改文件状态信息的时间)排序并显示;用-l:显示ctime并按名称排序;否则:按ctime排序,最新优先

       -C     list entries by columns
              按列列出项目

       -d, --directory
              list directories themselves, not their contents
              列出目录本身,而不是目录的内容


       -g     like -l, but do not list owner
              像-l,但不要列出所有者

       -i, --inode
              print the index number of each file
              打印每个文件的索引号

在这里插入图片描述

 -I, --ignore=PATTERN
              do not list implied entries matching shell PATTERN
              不列出匹配shell模式的隐含项(大写i)

不列出以 h开头的文件
在这里插入图片描述

   -k, --kibibytes
          default to 1024-byte blocks for disk usage
          以KB(千字节)为单位显示文件大小;

   -l     use a long listing format 
         使用长列表格式
         以长格式显示目录下的内容列表。输出的信息从左到右依次包括文件名,文件类型、权限模式、硬连接数、所有者、组、文件大小和文件的最后修改时间等;
         也可以直接 ll命令
         
    -L, --dereference
          when showing file information for a symbolic link, show information 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

   -p, --indicator-style=slash
          append / indicator to directories
          向目录追加/指示符

   -Q, --quote-name
          enclose entry names in double quotes
          将条目名称用双引号括起来

   -R, --recursive
          list subdirectories recursively
          递归处理,将指定目录下的所有文件及子目录一并处理;
   -s, --size
          print the allocated size of each file, in blocks
          以块的形式打印每个文件的分配大小

   --help display this help and exit
   ubuntu@ip-172-31-3-107:~$ ls --help

   --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 (powers of 1024) or KB,MB,... (powers of 1000).
   SIZE参数是一个整数和可选的单元

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).

人性化展示

ls -h filepath h表示human, 加-h参数得到人好读的文件大小

排序

默认按文件名排序

以文件名反序排列

  -r, --reverse
              reverse order while sorting
              -以文件名反序排列并输出目录内容列表;

按文件大小

 -S     sort by file size, largest first

使用sort排序

   --sort=WORD
              sort by WORD instead of name: none (-U), size (-S), time (-t), version (-v), extension (-X)
              ubuntu@ip-172-31-3-107:~$ ls -X
ubuntu@ip-172-31-3-107:~/word1$ ls -sort -t

根据修改时间排序

  -t     sort by modification time, newest first

按访问时间排序

  -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
        			显示访问时间并按名称排序;否则:按访问时间排序,最新的优先

按文件版本排序

  -v     natural sort of (version) numbers within text
               按文本中的自然类型(版本)数字排序

按扩展名的字母顺序排序

  -X     sort alphabetically by entry extension
       			按扩展名的字母顺序排序

猜你喜欢

转载自blog.csdn.net/uotail/article/details/88108613
今日推荐