• find big file


    #!/bin/bash
    
    #command usage description
    function usage()
    {
    	echo -e "Usage:nt$0 DIR_NAME"
    	exit
    }
    
    # Check if user is root
    if [ $(id -u) != "0" ]; then
        echo "Error: You must be root to run this script, please use root to use it!!!"
        exit 1
    fi
    
    #judge the argv
    if [ $# -ne 1 ]
    then 
    	echo "the usage of the command is ERROR!!!"
            usage
    fi
    
    dir_name=$1
    i=0
    
    if [ ! -d $dir_name ]
    then 
    	echo "the argv is not a direction!!!"	
    	usage
    else
    	cd $dir_name
    	echo "pwd: " `pwd`
    	du -ahS | sort -nr | 
    	while read line 
    	do	
    		myline=`echo $line | awk '{print $2}'`
    		if [ -f $myline ] && [ $i -lt 5 ] 
    		then 
    			echo $line 
    			let i++ 
    		fi
    	done 
    fi
    #!/bin/bash
    
    #command usage description
    function usage()
    {
    	echo -e "Usage:nt$0 DIR_NAME"
    	exit
    }
    
    # Check if user is root
    if [ $(id -u) != "0" ]; then
        echo "Error: You must be root to run this script, please use root to use it!!!"
        exit 1
    fi
    
    #judge the argv
    if [ $# -ne 1 ]
    then 
    	echo "the usage of the command is ERROR!!!"
            usage
    fi
    
    dir_name=$1
    i=0
    
    if [ ! -d $dir_name ]
    then 
    	echo "the argv is not a direction!!!"	
    	usage
    else
    	cd $dir_name
    	echo "pwd: " `pwd`
    	du -ahS | sort -nr | 
    	while read line 
    	do	
    		myline=`echo $line | awk '{print $2}'`
    		if [ -f $myline ] && [ $i -lt 5 ] 
    		then 
    			echo $line 
    			let i++ 
    		fi
    	done 
    fi


  • 相关阅读:
    align 的用法
    layui 验证用法
    C# Post请求方法
    SQL 查询今天、昨天、7天内、30天的数据
    对Dijkstra名字发音的看法
    Ubuntu桌面图标消失且右键失效的解决办法
    Ubuntu下安装与配置Matlab
    ns 简单网络模拟
    JAVA包含第三方包的部署方法
    Ubuntu下配置ftp服务端
  • 原文地址:https://www.cnblogs.com/james1207/p/3268669.html
Copyright © 2020-2023  润新知