Hi All,
Can you please provide some pointers to move files from Base path to multiple paths in efficient way.Folder Structure is already created.
I don't want to move directory structure. I want to move files from that source path to destination path on daily basis. I would need pointer to write a bash script to make sure aaa.txt would exactly go and sit only from
/Path/AdminUser/User1/1111/Reports/ to
/Path/User1/1111/Reports/ ........
One of geek folk helped provided with inputs to start as below, It still threw error, can we also write it in an efficient way?
Can you please provide some pointers to move files from Base path to multiple paths in efficient way.Folder Structure is already created.
Code:
/Path/AdminUser/User1/1111/Reports/aaa.txt to /Path/User1/1111/Reports/aaa.txt
/Path/AdminUser/User1/2222/Reports/bbb.txt to /Path/User1/2222/Reports/bbb.txt
/Path/AdminUser/User2/3333/Reports/ccc.txt to /Path/User2/3333/Reports/ccc.txt
/Path/AdminUser/User2/4444/Reports/ddd.txt to /Path/User2/4444/Reports/ddd.txt
One of geek folk helped provided with inputs to start as below, It still threw error, can we also write it in an efficient way?
Code:
#!/bin/bash
dir1=/Path
for i in "$dir1"/AdminUser/*; do
if [[ -d $i && ! -L $i ]]; then
dir2="${i##*/}"
for j in "$i"/*; do
if [[ -d $j && ! -L $j ]]; then
j="${j##*/}"
mv "$i"/"$j"/Reports "$dir1"/"$dir2"/"$j"/
fi
done
fi
done