copy and rename file..

hi all,

I have one config folder and updates folder.updates folder contains file tmp_2.0_20201208_45.xml and config folder contains file tmp.xml.When the tmp_2.0_20201208_45.xml file is copied in the config folder the name of this file is changed in config folder again as tmp.xml(old filename)(After copied this tmp_2.0_20201208_45.xml in config folder name is changed again as tmp.xml file.) plz help me how to write shell script ...

install 'File::Copy::Recursive' module and mentioned your your input_dir and output directory at the corresponding place.

perl -e 'use File::Copy::Recursive qw(dircopy); dircopy('/home/input_dir', '/home/output_dir');

thanks..i dose not want code in perl..i want shell script in c

from inside your updates directory:-

cp -f tmp_2.0_20201208_45.xml ../config

use cp command with full OR relative file paths like:
cp tmp_2.0_20201208_45.xml <path>/

(After copied this tmp_2.0_20201208_45.xml in config folder name is changed again as tmp.xml file.)

As anurag.singh suggests also try full paths

e.g.

cp -f <full_path>/updates/tmp_2.0_20201208_45.xml <full_path>/config/tmp_2.0_20201208_45.xml

try

cp -f <full_path>/updates/"tmp_2.0_20201208_45.xml" <full_path>/config/

thanks..but from this code can be change the name of file from tmp_2.0_20101208_45.xml into tmp.xml...

---------- Post updated at 01:22 PM ---------- Previous update was at 12:44 PM ----------

thanks..but tmp_2.0_20201208_45.xml file will changed again and again..(tmp_2.0_20201208_46.xml ...)and copied in config folder then rename as tmp.xml..so we can not give the name of the file "tmp_2.0_20201208_45.xml" as u wrote in ur code so what i wrote in place of it..