linux中文件夹中文件排序显示
在查看Linux文件的时候,大家都习惯用ls 命令来对进行查看。
ls的参数很多,这里就不一一说明了,有兴趣的直接在控制台 ls --help 可以看到所有信息。
文件夹中文件多的时候,大家就会想到要排序了。
排序的话在ls 命令中使用的是-t -c -u参数。
敲入ls --help 命令查看说明:
-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
-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
-c 创建时间
-t 修改时间
-u 访问时间
顺序排列
上面说明按照修改时间进行排序,最新修改的在最上面。
例如:ls -alt
倒序排列
如果文件多了,我们希望能倒序排列,这个linux也是支持的。
倒序的话是增加 -r参数。-r(--reverse)表示颠倒的意思。
下面是参数的help解释说明
-r, --reverse reverse order while sorting
例如:ls -altr
上面例子中添加的 -a -l 参数,表示所有文件和长清单的显示格式,--help中分别表如下解释:
-a, --all do not ignore entries starting with
-l use a long listing format
如您想了解更多关于ls 命令的话,可以在--help中进行查看相关参数说明。