hi All, Any one answer my requirement.
I have source location
src_dir="/home/oracle/arun/IRMS-CM"
My Target location
dest_dir="/home/oracle/arun/LiveLink/IRMS-CM/$dc/$pc/$ct"
my source text files check with below example.text file content
$fn "\t" $dc "\t" $pc "\t" $ct
file1.doc US SANZA ENCLOSRE
FILE2.DOC CA SUPER
FILE3.DOC DA SLIDE SAVE
FILE4.DOC SA DOC
the above text file is source text file check with source location files and destination location files.
if i copied files from source to destination location then
files copied successfully then count successfully copied =?
if files not copied successfully count Error files not copied=?
(cause of error if destination folders not exist and source file not exist at source location)
in above source txt file while coping files to destination respective folders
ex; file1.doc---> $dc/$pc$ct
us/sanza/enclosure(file1.doc in enclosure folder )
as well as
ex; file2.doc -->$dc/$pc$ct
CA/ /SUPER(file2.doc in super folder directly if $pc flolder not exist then copy to $ct folder)
I developed below code
IFS=$'\n'
while read -r line; do
fn=$(echo $line |awk -F "\t" '{print $1}')
dc=$(echo $line |awk -F "\t" '{print $2}')
pc=$(echo $line |awk -F "\t" '{print $3}')
ct=$(echo $line |awk -F "\t" '{print $4}')
src_dir="/home/oracle/arun/IRMS-CM"
dest_dir="/home/oracle/arun/LiveLink/IRMS-CM/$dc/$pc/$ct"
if [ -d $dest_dir ]; then
for FILE in $src_dir/{$fn,*/$fn}
do
if [ -f $FILE ];then
cp $FILE $dest_dir && ((Succ_Cnt++)) || ((Err_Cnt1++))
fi
done
else
echo " $dest_dir directory Does Not exists!" >> Test4.txt
Err_Cnt=$(wc -l<Test4.txt)
fi
done< example.txt
please correct that code
count the successfullycopied files and error files count if not copied successfully
while using above code i'm unable to copy the files to $ct folder if $pc folder not exist then it shows error,but i need to copy files from source location to $ct if $pc folder not exist then jump to $ct folder
another issue is errorfiles count(we are not able to count suucessfully copied count and error files not copied files count at a once time with check from source location according example.txt file)
note :
No need to create destination folder if folders not exist at destionation just print cause of error in another error.txt file
then we check error.txt file and create folders manually.
Please suggest and help for in this code and replay with new code
coping files to source location if files copied successfully copied then count number of files counted and error files not copied successfully count