1、查看哪个文件占用最大
查看前十名磁盘空间用户,到第11行,sed会删除列表的剩余部分,然后给列表中每行一个行号。要让行号和磁盘空间文本
位于同一行,用N命令将文本行合并在一行。然后用gawk命令清理,在行号后,加一个冒号(:),还给每行文本的输出行中的每个字段放了一个制表符。这样就生成了一个格式精致的前十名
磁盘空间用户列表了
[root@digitcube-test1 qingyun]# du -Sh /home/*| sort -rn | sed ‘{11,$D;=}‘ | sed ‘N;s/\n/ /‘ | gawk ‘{print $1":""\t" $2"\t" $3"\n"}‘ 1: 1020K /home/nexus/sonatype-work/nexus/storage/central/org/springframework/spring-context/2.5.6 2: 1020K /home/nexus/sonatype-work/nexus/storage/central/ant/ant/1.6.5 3: 1012K /home/nexus/sonatype-work/nexus/storage/central/org/springframework/spring-beans/2.5.6 4: 1012K /home/maven/.m2/repository/org/xerial/snappy/snappy-java/1.0.4.1 5: 1008K /home/home/hadoop/jstorm/dc_topology/tmp/org/apache/hadoop/hdfs/server/namenode 6: 1008K /home/home/hadoop/hadoop-1.0.4/docs/api/org/apache/hadoop/mapreduce 7: 1008K /home/hadoop/sam/datatask/doubixiyou_1290 8: 1008K /home/hadoop/hadoop-1.0.4/docs/api/org/apache/hadoop/mapreduce 9: 1004K /home/home/hadoop/jstorm/dc_topology/tmp/kafka/log 10: 1000K /home/maven/.m2/repository/org/xerial/snappy/snappy-java/1.0.3.2
2、创造加了日期的前十名磁盘空间用户报告的脚本
[root@digitcube-test1 tmp]# vim file_siz.sh
本文出自 “散人” 博客,请务必保留此出处http://zouqingyun.blog.51cto.com/782246/1696340
原文地址:http://zouqingyun.blog.51cto.com/782246/1696340