0

I'm running a FAMP (FreeBSD, Apache...) box and just updated Apache to 2.4. We have somewhere around 100 sites running on this box as vhosts, and they all have their own separate config file for awstats, all of which now have an out of date LogFile reference because it's pointing to the apache22 folder instead of the new apache24. I'd like to be able to quickly update all of those in one pass, without having to update each file or run the command manually for each one.

I know I could easily setup the apache22 folder as a symlink, but I'd rather have something more permanent in place, but is also hopefully easy. Any ideas?

0

A liitle Script should do the work for you. That is just how it could looks like because i do not know your paths. The script-part 'sed' will change the path directly in the conf file! So be careful with typo! Better test it before!

#!/bin/bash
for i in `ls /path/to/the/user*/awstats.conf`
do
        sed -i 's|'OldPath'|'NewPath'|g' $i
done
  • I tried this and got the following error: sed: 1: "/usr/local/www/awstats/ ...": extra characters at the end of l command – aron.duby Apr 1 '15 at 16:20
  • did a bit more research, running sed with the i flag you have to specify a backup extension so sed -i '.bak' 's/oldpath/newpath/g' $i worked, if you'd like to update your answer I'll mark it as accepted – aron.duby Apr 1 '15 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.