linux脚本的管道流,shell数据流重定向和管道命令

按照文件大小写来排序

[root@localhost110 ~]# ls -l|sort -t ' ' -k 5 -n

总用量 1740

-rw-r--r--. 1 root root 6 10月 16 02:17 1

-rw-r--r--. 1 root root 6 10月 16 02:17 B.php

-rw-r--r--. 1 root root 8 10月 16 01:59 a.php

-rw-r--r--. 1 root root 11 10月 16 02:06 A.php

-rw-r--r--. 1 root root 42 10月 16 01:42 log

-rw-r--r--. 1 root root 140 10月 16 02:02 ab

-rw-r--r--. 1 root root 143 10月 16 01:59 b.php

-rwxrwxrwx. 1 root root 272 1月 27 2016 mysql_listen.sh

-rw-r--r--. 1 root root 1112 10月 16 02:17 D.php

-rw-------. 1 root root 1416 1月 13 2016 anaconda-ks.cfg

drwxr-xr-x. 2 root root 4096 1月 13 2016 公共的

drwxr-xr-x. 2 root root 4096 1月 13 2016 模板

drwxr-xr-x. 2 root root 4096 1月 13 2016 视频

drwxr-xr-x. 2 root root 4096 1月 13 2016 图片

drwxr-xr-x. 2 root root 4096 1月 13 2016 文档

drwxr-xr-x. 2 root root 4096 1月 13 2016 下载

drwxr-xr-x. 2 root root 4096 1月 13 2016 音乐

drwxr-xr-x. 2 root root 4096 1月 13 2016 桌面

-rw-r--r--. 1 root root 10033 1月 13 2016 install.log.syslog

-rw-r--r--. 1 root root 46328 1月 13 2016 install.log

-rwxr-xr-x. 1 root root 1640731 6月 7 09:40 composer.phar

设置显示方式

export TIME_STYLE='+%Y-%m-%d %H:%M:%S'

[root@localhost110 ~]# ls -l|sort -k 6

总用量 1740

-rw-r--r--. 1 root root 10033 2016-01-13 17:42:57 install.log.syslog

-rw-r--r--. 1 root root 46328 2016-01-13 17:48:20 install.log

-rw-------. 1 root root 1416 2016-01-13 17:48:28 anaconda-ks.cfg

drwxr-xr-x. 2 root root 4096 2016-01-13 17:52:58 公共的

drwxr-xr-x. 2 root root 4096 2016-01-13 17:52:58 模板

drwxr-xr-x. 2 root root 4096 2016-01-13 17:52:58 视频

drwxr-xr-x. 2 root root 4096 2016-01-13 17:52:58 图片

drwxr-xr-x. 2 root root 4096 2016-01-13 17:52:58 文档

drwxr-xr-x. 2 root root 4096 2016-01-13 17:52:58 下载

drwxr-xr-x. 2 root root 4096 2016-01-13 17:52:58 音乐

drwxr-xr-x. 2 root root 4096 2016-01-13 17:52:58 桌面

-rwxrwxrwx. 1 root root 272 2016-01-27 05:54:08 mysql_listen.sh

-rwxr-xr-x. 1 root root 1640731 2016-06-07 09:40:58 composer.phar

-rw-r--r--. 1 root root 42 2016-10-16 01:42:05 log

-rw-r--r--. 1 root root 8 2016-10-16 01:59:03 a.php

-rw-r--r--. 1 root root 143 2016-10-16 01:59:45 b.php

-rw-r--r--. 1 root root 140 2016-10-16 02:02:19 ab

-rw-r--r--. 1 root root 11 2016-10-16 02:06:07 A.php

-rw-r--r--. 1 root root 6 2016-10-16 02:17:17 1

-rw-r--r--. 1 root root 6 2016-10-16 02:17:21 B.php

-rw-r--r--. 1 root root 1112 2016-10-16 02:17:30 D.php

wc指令

wc [-lwm] filename 统计功能

-l 统计行

-w 统计词

-m 统计字符

[root@localhost110 ~]# wc -l log

8 log

[root@localhost110 ~]# cat log|wc -l

8

[root@localhost110 ~]# cat log|wc -w

10

[root@localhost110 ~]# cat log -n

1 php

2 ajax

3 java

4 python

5 nginx mysql

6 GO p erlang

7 PHP5

8

[root@localhost110 ~]# cat log|wc -m

53

[root@localhost110 ~]# cat log1|wc -m

12

[root@localhost110 ~]# cat log1 -n

1 p h p

2 1 2 3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值