In Linux I have a permanent directory structure which stores 5 different types of files for each month of the year going back to 2005, like so
2005/01/file1 file2 file3 file4 file5
2005/02/file1 file2 file3 file4 file5
...
2015/11/file1 file2 file3 file4 file5
2015/12/file1 file2 file3 file4 file5
I need to replace each instance of file1 from an identical temporary directory structure, except each leaf in the temporary structure only has file1 (file2/3/4/5 do not exist). How can I do one bulk command to rename each file1 to file1.bak in the permanent structure, and then a command to copy each new file1 instance to the proper location in the permanent structure?
rename 1 1.bak 20??/??/file1. Or you can use a for loop.for dir in 20??/??; do mv ${dir}/file1 ${dir}/file1.bak. As for copying to permanent directory, it's just a matter of prefixing the parent directory and using the same logic of the for loop. - alvits