ls 排序

  首先我们通过man 来看看 ls其中有几项;

  • -S     sort by file size : 按大小降序

--sort=WORD
sort by WORD instead of name: none -U, extension -X, size -S, time -t, version -v

--time=WORD
with -l, show time as WORD instead of modification time: atime -u, access -u, use -u, ctime -c, or status -c; 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, +FORMAT. FORMAT is interpreted like ‘date’; if FORMAT is FORMAT1<newline>FORMAT2, 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 按时间升序
  • -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
  • -X     sort alphabetically by entry extension
ls -lS    按大小降序
ls -l | sort -n -k5 按大小升序 ls -lrt 按时间降序 ls -lnt 按时间升序 ls -l | sort -k9 按文件名升序(这是ls的默认输出方式) ls -lr 按文件名降序
ls -l | sort -rk9 按文件名降序

附:

ls对当前目录和文件大小排序

du -s * | sort -nr

只对当前目录排序,并用直观的大小显示出来

for i in $(ls -l |grep '^d' |du -s * |sort -nr|awk '{print $2}');do du -sh $i;done

ls 排序的更多相关文章

  1. Linux ls 排序

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/hongweigg/article/details/37693029 在Linux中查看文件,有时须要 ...

  2. linux下 ls 排序

    ls -lS                       按大小降序排列 ls -l | sort -n -k5    按大小升序 ls -lrt                       按时间降 ...

  3. day03-课堂笔记

    # 数据类型"""# int# py2存放长整型:long# py3环境,所以整型均由int存储num1 = -10num2 = 10000000000000000000 ...

  4. Linux 集锦(持续更新中)

    // 获取文件夹下的代码总行数 find . -name "*.*" | xargs wc -l // ls 排序 ls -lt 按照最后修改时间降序 ls -lrt 按照时间升序 ...

  5. 08 Python基础数据结构

    目录: 1) 列表 2) 元组 3) 字符串 4) bytes 5) bytearray 6) 字典 7) 集合 8) 冻集合 """1. 列表特性2. 创建3. 增加4 ...

  6. Linux学习-基本命令文件操作

    终端 1.多个终端 连接linux的客户端可以理解为终端. 命令:tty查看终端 2.不同终端之间的通讯 [root@wyx wyx]# echo 123 > /dev/pts/1 把123发给 ...

  7. Linux 究级基础入门命令整理

    Linux 究级基础入门命令整理 条条框框,三三两两,怎讷个这么多,哈哈!no zuo no die. 纯粹个人菜鸟笔记,望大神笑纳! 后续,未完!! 查看系统信息 uname -a - 查看内核/操 ...

  8. ls按时间排序输出文件列表

    文件转自:http://www.2cto.com/os/201303/197829.html ls按时间排序输出文件列表   首先,ls --help查看ls相关的与时间排序相关的参数:   > ...

  9. linux_常用命令_(ls, lsof,nslookup)_查看文件按照时间排序

    平时收集些用到的命令 方便使用 1:  ls -lrt 按时间排序  展示 2:nslookup  查看dns解析 3:lsof -p 进程号 lsof `which httpd` //那个进程在使用 ...

随机推荐

  1. js格式化日期,获取当月的第一天,与最后一天.

    //格式化日期 function setDate(date){   y=date.getFullYear();   m=date.getMonth()+1;   d=date.getDate();   ...

  2. iOS-GCD多线程

    GCD GCD -- Grand Central Dispatch 是基于C语言的底层API 用Block定义任务,将任务添加到线程中使用.集中管理 1.GCD的执行函数 //同步 dispatch_ ...

  3. UI1_UITableViewHomeWork

    // // AppDelegate.m // UI1_UITableViewHomeWork // // Created by zhangxueming on 15/7/14. // Copyrigh ...

  4. change

    #include<iostream> using namespace std; int main() { double a; cin>>a; cout<<a< ...

  5. 这是html5中WebGL的演示

    这是html5中WebGL的演示,让我们与他人分享爱您发送短消息.每次你进入它使用不同的位置,新的爱情点被添加到全球.让世界更明亮的地方与你的朋友分享! 源文件:部分代码:<!DOCTYPE h ...

  6. 麦子学院Android开发Java教程ClassCastException 错误解析

    现在Java编程中经常碰到ClassCastException 错误,ClassCastException 是 JVM 在检测到两个类型间的转换不兼容时引发的运行时异常.此类错误通常会终止用户请求.本 ...

  7. 14.Apache配置

    环境:                                                      ↗  atl.example.com  (192.168.1.101) ↗ www.e ...

  8. UBUNTU12.4 安装磊科无线网卡驱动

    UBUNTU12.4 安装磊科无线网卡驱动 在淘宝低价买了一个网卡,回来发现不能用 ,擦 无语了. 无赖只能在网上各种找驱动,编译 安装 .今天在终于安装好了WIFI驱动了: 下载地址:https:/ ...

  9. linux 安装sysstat使用iostat、mpstat、sar、sa(转载)

    使用yum安装 #yum install sysstat sysstat的安装包是:sysstat-5.0.5-1.i386.rpm,装完了sysstat-5.0.5-1.i386.rpm后 就会有i ...

  10. 下载服务器dll文件并动态加载

    1.新加一个类库 namespace ClassLibrary1 { public class Class1 { public int Add(int a, int b) { return a + b ...