文件打包歸檔

#! /bin/bash
cd /home/tomcat/inimsbms/inimsfiles/
i=2016
cur_year=`date +%Y`
echo $cur_year
while [ $i -le $cur_year ]
do
   echo $i
   
  if ls -l  *"$i"*.D >/dev/null
  then
   if [ $? -eq 0 ] 
   then
      tar -cvzf "$i".gz.tar *"$i"*.D
      rm -f *"$i"*.D
   else
      echo "command failed " 
      break
   fi   
  fi
  if ls -l *.tar >/dev/null 
  then
    mv *.tar /home/tomcat/inimsbms/aa/
  fi
   i=`expr $i + 1`
done

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章