I am creating a shell script to take input from CSV files, having two rows ( One Column mentioning time and another file string ).. My script works when there is one row... But it isnot working in multiple rows and also how can i know which row it is searching didnt got the files .
Sample file:
1300,N213
1245,N218
1400,N222
1600,N225
Code, I am trying to make it work.
#!/bin/bash
tr_filepath=/var/opt/data/nms_umts_pms_seg/segment1/
echo "Folder to search for traces ${tr_filepath}"
tr_newpath=/var/opt/ericsson/nms_umts_pms_seg/segment1/edos/4G/
CNTRL_FILE=/home/vx622325/filematch.csv
echo "File Contents of ${CNTRL_FILE} to match with pattern"
for i in $CNTRL_FILE;
do
t=$(cat $i | awk -F"," '{ print $1}')
n=$(cat $i | awk -F"," '{ print $2}')
X=`find "$tr_filepath" -type f -iname "A*."$t"*,*="$n"*.bin.gz"`
echo -e "Traces To Copy \n $X\n" >> /home/vx622325/result_`date +"%d_%m_%Y"`.csv
if [ -d "$tr_newpath" ]; then
y= cp -rp $X $tr_newpath
else
echo "Output folder $tr_newpath not found" > /home/vx622325/result_`date +"%d_%m_%Y"`.csv
fi
done
Files to search for
A20190118.2200+0300-2201+0300_SubNetwork=ONRM_RootMo,SubNetwork=N213,MeContext=N213,ManagedElement=1_rnc_gpehfile_Mp0.bin.gz
A20190118.2200+0300-2201+0300_SubNetwork=ONRM_RootMo,SubNetwork=N213,MeContext=N213,ManagedElement=1_rnc_gpehfile_Mp10.bin.gz
A20190118.2200+0300-2201+0300_SubNetwork=ONRM_RootMo,SubNetwork=N213,MeContext=N213,ManagedElement=1_rnc_gpehfile_Mp11.bin.gz