linux统计文件大小-以KB、MB、GB、TB为单位
fileSize=`hadoop fs -ls /data/internetLog/home/DPI/idc/20180806/*201808062[0-2]* | awk 'BEGIN{ sum=0 };{ sum+=$5 };END{ print sum}'` if [ ${fileSize} -gt $[1024*1024*1024*1024] ] ; then fileSize=`echo "scale=1;${fileSize}/1024/1024/1024/1024" | bc`T elif [ ${fileSize} -gt $[1024*1024*1024] ] ; then fileSize=`echo "scale=1;${fileSize}/1024/1024/1024" | bc`G elif [ ${fileSize} -gt $[1024*1024] ] ; then fileSize=`echo "scale=1;${fileSize}/1024/1024" | bc`M elif [ ${fileSize} -gt 1024 ] ; then fileSize=`echo "scale=1;${fileSize}/1024" | bc`KB fi
---统计日期为2018-11-25的文件或目录名称
hadoop fs -ls /tmp/logs/hwcdm/logs/ | grep 2018-11-25 | awk '{print $8}' | wc -l ;
--删除日期为2018-11-25的文件或目录
hadoop fs -ls /tmp/logs/hwcdm/logs/ | grep 2018-11-25 | awk '{print $8}' |xargs hadoop fs -rm -r ;
本文来自博客园,作者:业余砖家,转载请注明原文链接:https://www.cnblogs.com/yeyuzhuanjia/p/16434014.html