shell学习(五)

文本排序及统计

  • ls列表顺序
    默认按字母升序排列
    -S:按文档大小降序排列
    -t:按文档的修改时间降序排列-
    -r :反序排列
[root@localhost test]# ls -lh -S demo*.sh  //ls -lh 显示文件大小
-rw-r--r-- 1 root root 334 926 14:18 demo14.sh
-rw-r--r-- 1 root root 183 926 14:42 demo15.sh
-rw-r--r-- 1 root root 176 926 10:12 demo10.sh
[root@localhost test]# ls -lh -rS demo*.sh
-rw-r--r-- 1 root root  26 924 15:04 demo2.sh
-rw-r--r-- 1 root root  33 924 16:05 demo5.sh
-rw-r--r-- 1 root root  43 924 15:27 demo3.sh
[root@localhost test]# ls -lh -t demo*.sh
-rw-r--r-- 1 root root  88 926 15:09 demo19.sh
-rw-r--r-- 1 root root 137 926 15:00 demo18.sh
-rw-r--r-- 1 root root  61 926 14:49 demo17.sh

  • uniq
    用法1: uniq文件 ; 用法2∶命令| uniq
    uniq -c 统计重复次数
  • sort
    基本用法
    用法1 : sort文件 ;
    用法2∶命令│ sort常用命令选项
    -u︰去除重复行
    -n :按数字顺序升序排列- -r∶反向排序
    -k :优先对第几列的内容排序
//按内存使用量排序
[root@localhost test]# ps aux | head -1;ps aux | sort -nr -k4
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root        2036  0.0 15.5 1118636 285468 ?      Ssl  9月24   1:34 /usr/libexec/packagekitd
root        2406  0.3  7.8 4224268 143232 tty2   Sl+  9月24  13:58 /usr/bin/gnome-shell
root       16418  0.0  6.9 3095244 127472 tty2   Sl+  9月24   3:11 /usr/lib64/firefox/firefox
root        2758  0.0  3.5 1180632 65680 tty2    Sl+  9月24   0:16 /usr/bin/gnome-software --gapplication-service

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值