Hey guys,
I need to know how to locate all .htaccess files on the server and make a backup of them in the folder they reside before I run a script to modify all of them.
So basically taking dir1/.htaccess and copying it as dir1/.htaccess_bk
dir2/.htaccess copying as dir2/.htaccess_bk
etc...
find / -name ".htaccess" -exec cp (NOT SURE WHAT GOES HERE) {} \;
Can someone explain the proper cp usage for this example?
Much appreciated.
---------- Post updated at 01:01 PM ---------- Previous update was at 12:48 PM ----------
Nevermind,
I think I figured it out
find <start_directory> -iname ".htaccess" -exec cp {} {}_bak \;
---------- Post updated at 01:31 PM ---------- Previous update was at 01:01 PM ----------
Okay so that seemed to work as intended.
Now I'm curious... I have a copy of each original .htaccess file named .htaccess_bak sitting along side each original just incase my script to update them all doesnt work as planned and I need to revert to the backups..
How can I accomplish either copying the contents from the backup file to the original file, or renaming the backup files all the .htaccess to overwrite the originals?
Something like...
find / -name ".htaccess_bak" exec rename {} ?.htaccess? \;
Can someone explain the proper syntax to accomplish something like this?
Thanks