标签:ash 查询 $1 lse div The lte else use
1 查询具体表分区大小,以字节展示
hadoop fs -du /user/hive/warehouse/treasury.db/dm_user_excercise > dm_user_excercise.txt
2 定义shell脚本:
#!/bin/bash # size18=0 size17=0 size16=0 filename=$1 echo $filename while read line do num=` echo $line | cut -d " " -f 1` #echo $num if [[ $line =~ "2018-" ]] ; then let size18=$size18+$num elif [[ $line =~ "2017-" ]] ; then let size17=$size17+$num elif [[ $line =~ "2016-" ]] ; then let size16=$size16+$num else echo "2018 2017 2016年之外的分区" echo $line fi done < $filename let size18=$size18/1024/1024/1024 let size17=$size17/1024/1024/1024 let size16=$size16/1024/1024/1024 echo "2018分区表大小G: "$size18 echo "2017分区表大小G: "$size17 echo "2016分区表大小G: "$size16
3 调用命令:
sh filter5.sh dm_user_excercise.txt
标签:ash 查询 $1 lse div The lte else use
原文地址:https://www.cnblogs.com/chengjianxiaoxue/p/10150632.html