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 阅读(852) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: