yanmin

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

          前提數據
          file: 2012-07-11Mig.csv
          內容
          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)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 平安县| 雅江县| 东阳市| 卢龙县| 乐都县| 灵山县| 万荣县| 仁怀市| 辽阳市| 德保县| 河津市| 南召县| 共和县| 伊吾县| 盐城市| 沾益县| 香格里拉县| 山东省| 砀山县| 霍林郭勒市| 张掖市| 嵩明县| 安阳县| 太康县| 南丰县| 托克托县| 赤峰市| 合阳县| 东至县| 右玉县| 江川县| 大连市| 桂阳县| 准格尔旗| 罗定市| 皮山县| 交城县| 浦江县| 罗田县| 达日县| 卢龙县|