yanmin

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            16 隨筆 :: 1 文章 :: 9 評論 :: 0 Trackbacks

          前提數(shù)據(jù)
          file: 2012-07-11Mig.csv
          內(nèi)容
          project/test ,SAServicesHandler.java,N,N
          project/test,ADSLSARelocationServiceDetails.jsp ,Y,Y
          project/test,SAServicesHandler1.java,Y,N
          project/test1, SAServicesHandler.java ,N,Y
          project/test, SAServicesHandler.java ,Y,Y
          project/ test, SAServicesHandler.java   ,Y,Y

          運行命令:
          dos2unix 2012-07-11Mig.csv
          ./checkfile1.sh /home/test/2012-07-11Mig.csv  /home/test

          shell Code:

          #!/bin/sh
          #
          #   This script checks if the file name in the csv exists in the folder for deployment
          #   This script takes in two parameters
          #   First parameter is the full path to the csv file eg /home/test/2012-07-11Mig.csv
          #   Second parameter is the full path to the files for migration eg /home/test/2012-07-11Mig
          #   Check path and file has space, include new file and new path
          #
          cd  $2 #/home/test/2012-07-11 2nd variable

          #read /home/test/2012-07-11.csv file first variable

          #grep  ",N,N" $1 > existing_files.txt
          #yanmin for check all file, include new file and new path at 2012-07-12

          grep  ",*,*" $1 > existing_files.txt

          while read line   
          do   
           path=`echo $line | cut -d , -f1`
           filename=`echo $line | cut -d , -f2`
              file="$path/$filename"
              path1=$(echo $path | tr ' ' '_')
           
           # for check path and filename has space at 2012-07-12 start
           path1=$(echo $path | tr ' ' '_')
           filename1=$(echo $filename | tr ' ' '_')
           
           if [[ $path != $path1 ]]
           then
            echo "$file path has space, please check "
           fi
           
           if [[ $filename != $filename1 ]]
           then
            echo "$file file name has space, please check "
           fi
           #check path and filename has space at 2012-07-12 end
           
           if [ ! -f $file ]  
              then
               echo "$file does not exists, please check"
           fi
           
              done < existing_files.txt

          rm  existing_files.txt


           

          posted on 2012-07-12 16:48 yanmin 閱讀(863) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 公安县| 荥经县| 湄潭县| 克山县| 鄂托克前旗| 万源市| 肃宁县| 京山县| 民勤县| 宁安市| 威远县| 陆良县| 天镇县| 金坛市| 海门市| 勃利县| 库伦旗| 柏乡县| 满洲里市| 无锡市| 定陶县| 呼伦贝尔市| 新余市| 绩溪县| 离岛区| 南宁市| 彰武县| 东方市| 原平市| 黑水县| 南澳县| 武城县| 中西区| 龙泉市| 双峰县| 南郑县| 台东市| 离岛区| 米泉市| 温宿县| 藁城市|