用awk的printf就可以补位
# 仅适用于数字
printf "%04d\n" 86
echo 86|awk '{printf("%04d\n",$0)}'
#example------nohup sh hdfs_rename.sh 20160522 20160530 >>logrename 2>&1 &
datebeg=$1
dateend=$2
beg_s=`date -d "$datebeg" +%Y%m%d`
end_s=`date -d "$dateend" +%Y%m%d`
while [ "$beg_s" -le "$end_s" ]
do
date=${beg_s}
for i in `seq 99`
do
num1=`echo ${i}|awk '{printf("%06d\n",$0)}'`
num2=`echo ${i}|awk '{printf("%02d\n",$0)}'`
echo ${date}
echo ${num1}
echo ${num2}
hadoop fs -mv /xtrader/${date}/${num1}_* /xtrader/${date}/xtrader_UserInfo_${date}_${num2}.gz
done
echo ${date}
beg_s=`date -d"${beg_s}+1 day" +%Y%m%d`
done