Hi ,
I'm trying to move/copy the files inside the loop into a directory .
I tried the below code and the issue is the data is not copying into the created directory but the files are copying into another file
file_path="/home/etc"
Last_Day=20130930
mkdir $file_path/ARC_${Last_Day}
for files in $file_path/AB*$Last_Day*
do
dest_dir=$ARC_${Last_Day}
cp $file_path/$Last_Data $file_path/$dest_dir
done
When i check with set -x the last cp command is interpreted as
cp /home/etc/AB_20130930.log /home/etc/20130930
If I understood correctly , you mean to say copy files from /home/etc/AB*20130930* to /home/etc/ARC_20130930/
file_path="/home/etc"
Last_Day=20130930
if [ ! -d "$file_path/ARC_${Last_Day}" ]
then
mkdir -P $file_path/ARC_${Last_Day}
fi
dest_dir=${file_path}/ARC_${Last_Day}
for files in $file_path/AB*${Last_Day}*
do
echo "cp $files ${dest_dir}/
#cp $files ${dest_dir}/
done
First please check output of echo command, if it is satisfy your requirement, then only remove echo part and uncomment copy command which is after echo command.