![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How To replace Control-M in all files in a folder | padpa | Shell Programming and Scripting | 10 | 09-02-2008 07:58 AM |
| Auto copy for files from folder to folder upon instant writing | Bashar | UNIX for Advanced & Expert Users | 2 | 08-21-2008 03:44 PM |
| Parse the .txt file for folder name and FTP to the corrsponding folder. | MeganP | Shell Programming and Scripting | 3 | 07-03-2007 02:54 PM |
| Take a folder name and find it in another folder (Complicated) | hkhan12 | Shell Programming and Scripting | 5 | 09-06-2006 01:25 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Replace folder in all hosting accounts
I am trying to find out how to replace a folder that is located in every hosting account on the server I think this is possoble with a bash command of some sort?
The contents of this folder get updated from time to time and its getting to be a real pain doing it manually is there a way to do this via shell or some other method the folder in question is located inside the public_html folder of every account in the server. Jim |
|
||||
|
Sounds like you should find a different solution, longer term. What if users have customized some parts of the folder's contents? Do you intend to keep a backup, or just replace whatever is there? What about permissions? There is no single bash command which will do this, but a simple script would likely suffice. Assuming all accounts exist under /home, something like Code:
for f in /home/*/public_html/foldername; do
cp --backup /path/to/master/* ${f}/
home=${f%/public_html/foldername}
user=${home#/home/}
chmod $user $f/*
done
Assuming you have the master copy in /path/to/master, this will copy all files from that folder to each user's public_html/foldername, creating backup files if any files would be overwritten. (Your local implementation of cp might not have the --backup option -- you want to look into that first.) Then it uses a couple of simple substitutions to extract the user name from the path, and changes the ownership of all files in the destination folder so they belong to the user. This is pretty brute force; perhaps you want to loop over each individual file and decide whether or not you even need to replace what's possibly already there. Then you could also preserve the user's customization if the user has removed one of these files. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|