zoukankan      html  css  js  c++  java
  • Linux shell 对数据进行归档

      1 #!/bin/bash
      2
      3 DATE=$(date +%y%m%d)
      4 FILE=archive$DATE.tar.gz
      5 #The path to store the files you need to archive
      6 CONFIG_FILE=/tmp/zhangxl/file_to_archive
      7 DESTINATION=/tmp/zhangxl/$FILE
      8
      9 if [ -f $CONFIG_FILE ]
     10 then
     11     echo
     12 else
     13     echo
     14     echo "$CONFIG_FILE dose not exist"
     15     echo "Backup not completed due to missing Configuration File"
     16     echo
     17     exit
     18 fi
     19
     20 FILE_NO=1

     21 #Redirect Std Input to name of Config File
     22 exec < $CONFIG_FILE
     23 read FILE_NAME
     24 while [ $? -eq 0 ]
     25 do
     26     echo "file_name:" $FIEL_NAME
     27     if [ -f $FILE_NAME -o -d $FILE_NAME ]
     28     then
     29 #   FILE_LIST="$FILE_NAME"

        #注意这个变量,我过与自信,手打变量,结果打错了,拼写成FIEL,造成没有输出
     30         FILE_LIST="$FILE_LIST $FILE_NAME"    
     31         echo "==FILE_LIST==" $FILE_LIST
     32         echo
     33     else
     34         echo
     35         echo "$FILE_NAME ,dose not exist"
     36         echo "Obviously, I will not include it in this archive."
     37         echo "It is listed on line $FILE_NO of the config file."
     38         echo "Continuing to build archive list..."
     39         echo
     40     fi
     41     FILE_NO=$[$FILE_NO + 1 ]
     42     read FILE_NAME
     43 done
     44 echo "Startin archive . . ."
     45 echo
     46 tar  -zcf $DESTINATION   $FILE_LIST  2>/dev/null
     47 echo "Archive completed"
     48 echo "Resulting archive file is :$DESTINATION"
     49 echo
     50 exit

  • 相关阅读:
    2016——3——16 kmp 7题
    bzoj3942——2016——3——15
    bzoj1355——2016——3——15
    poj 3641 ——2016——3——15
    KMP之我见
    转自他人——————TLE之前,没有一个节点叫失败!!!
    省选必知
    bzoj1449————2016——3——14
    bzoj1070————2016——3——14
    bzoj1562[NOI2009]变换序列——2016——3——12
  • 原文地址:https://www.cnblogs.com/z977690557/p/14087203.html
Copyright © 2011-2022 走看看