Copy one file to multiple vhost directories
I'm administering a server that uses Plesk, and I need to copy the vhost.conf file to the conf folder for every vhost that begins with a certain word - we'll call it "unique".
To accomplish this, I tried running the following: # cp vhost.conf /var/www/vhosts/unique*/conf/ It does copy to one folder, but kicks out the following error for the rest: cp: omitting directory `/var/www/vhosts/unique1.com/conf/' cp: omitting directory `/var/www/vhosts/unique2.com/conf/' . . . I saw someone mention in another thread that it is not possible in Linux to copy one file to multiple directories without a shell script. If this is the case, could someone steer me to a script that would be helpful here? I'd be most grateful. Thanks, TWR |
Something like (untested!) may do it
Code:
for i in `ls /var/www/vhosts/unique*'; do Cheers, Tink |
Nice, Tink. Thanks for the quick reply. I'll give it a whirl.
|
Quote:
Cheers, Tink |
I ran the script (after changing the ' to a `) and it loops though all the folders inside each of unique0, unique1, etc instead of through the folder names themselves. To remedy this, I changed the command to:
for i in `ls /var/www/vhosts/`; do echo $i/conf/ # cp vhost.conf $i/conf/ done which echos out every folder in the /vhosts folder. Now all I need to do is all a conditional to only echo when the folder name contains the word "unique". Does it require a regular expression? Or are there simpler functions available like strpos in php? Any help would be appreciated. Thanks, TWR |
The "looping through" is easily remedied ...
Code:
for i in `ls -d /var/www/vhosts/unique*`; do Cheers, Tink |
All times are GMT -5. The time now is 03:09 PM. |