shell 补齐路径_shell 检查对应路径文件名,包含对含有空格路径和文件提示信息...

前提数据

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值