.sh file To rename existing file and copy new file

Hi All,

I am very new to shell scripting .
In my current task i want to create .sh file that will rename the existing file with appending _bu in it. And then copy new file .
e.g if i have file linuxFirst.java then i want to rename it to linuxFirst_bu.java ..Then want replace with latest linuxFirst.java.

Please guide me in this Task .

Thanks In advance

To rename all the .java files to _bu.java (Take backup before issuing the below command)

 
for i in *.java ; do new_name=`basename $i .java`; new_name=$new_name"_bu.java"; mv $i $new_name; done

replace the new java file

 
cp new_file_location destination
1 Like