Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am in the process of selling a network of 60 sites, they all have adsense with the same publisher id (google_ad_client="pub-xxxxxxxxxxxxxxxx") in all the files in the /home/ folder.

How can I do a mass search/replace from ssh to change my id to the buyer id?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

So you want to ssh to each machine and make that change? Should be pretty straightfoward with ssh and expect. Check out this stackoverflow question about that approach. Basically you just need to use expect to automate the ssh logins and then run something like this on every server (all via expect):

find /home/ -type f -maxdepth 1 -print0 | xargs -0 sed -i 's/pub-xxxxxxx/pub-12345/'

that will use sed to edit every file in-place in /home (and no lower in the tree) and replace occurrences of the first string with the latter.

If this is more than a one-time thing you can look into automating this more cleanly, like setting up passwordless ssh logins to eliminate the expect step. However if I understand your question correctly you are really looking for a one-time solution, which is why I say use expect this way.

share|improve this answer
    
Thanks that helped, I actually only need to login on one machine as root, it's a dedicated server. –  jejasmin Jan 10 '11 at 23:30
    
Oh ha, then that's a lot easier. Just log in and run a sed script! –  Phil Hollenback Jan 11 '11 at 0:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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