Currently i am building a script like based on region parameter it will filter the records in config file and then it will create a text file like ab.txt and it will read the path location in that file and now i need to compare the files name in the config file to files in the path of the config file if the file exists it has to say file exists and list of the file that are exists if file not exists list of the files that are not exists
note: in my real time file name is going to change daily in that first three characters is only going to match
My script
#!/bin/bash
SOURCE_CONF="./test.properties"
#input region name
region="$1"
echo $region
cwd=$(pwd)
calu=$(grep $region test.properties > ab.txt)
IFS=$'\n'
#loop to read the config one line at a time
while read p; do
echo $p
a=($(echo "$p" | tr '|' '\n'))
echo "Region is:" "${a[0]}"
echo "path is:""${a[3]}"
path="${a[3]}"
#remove white space before path
echo $cwd
FOO_NO_LEAD_SPACE="$(echo -e $path | tr -d '[:space:]')"
echo "path is:"$FOO_NO_LEAD_SPACE
# change to path spacified in the config file
sh -c 'cd $FOO_NO_LEAD_SPACE && echo "in the subshell" && echo $pwd && echo "exit subshell" && exec pwd'
echo $cwd
echo "--------------------"
done < ab.txt
echo "abc"
My config file
region | Module |country code | filepath |filename
APJ | WDMD | MYS |/c/Users/vattikun/desktop | MYS*ADPGV*.XML
APJ | WDED | EUR|/c/Users/vattikun/desktop/Payroll Support | EUR*ADPGV*.XML
APJ | WDMD | RER|/c/Users/vattikun/desktop/Payroll Support | RER*ADPGV*.XML
APJ | WDJD | EYZ|/c/Users/vattikun/desktop/Payroll Support | EYZ*ADPGV*.XML
EMA | WDMD | AUS|/c/Users/vattikun/desktop | AUS*ADPGV*.XML
EMA | WDMD | AYS| /c/Users/vattikun/desktop | AYS*ADPGV*.XML
AMS | WDMD |ITI| /c/Users/vattikun/desktop | ITI*ADPGV*.XML
AMS |WDMD |AYS| /c/Users/vattikun/desktop | AYS*ADPGV*.XML