Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After a bit of googling / research on my own i haven't found a definitive answer,

I'm looking to search the entire /var/www/html/ folder for occurances of "" and replace them with a server IP address (we're moving the database off of the local box).

This goes for Localhost & While i could just run

find * | xargs sed -i a/

twice, once replacing and localhost, i'd rather not have to run two commands.

Am i able to do a OR statement without it breaking?

Something like:

find * | xargs sed -i a/|localhost/ser.ver.ip.addr/g


I found a slightly more reliable method of doing a search & replace,

find * -type f -exec sed -i 's/' {} \;

However i can't seem to get the search statement to match OR localhost.

share|improve this question
up vote 2 down vote accepted
find . -type f -print | xargs sed -i -e 's/' -e 's/localhost/'
share|improve this answer

I think you would have to put it in quotes:

find * | xargs sed -i "a/|localhost/ser.ver.ip.addr/g"
share|improve this answer
and of course: find . -type f – chris Jul 6 '09 at 23:17
with or without quotes / ticks it seemed to work. – GruffTech Jul 6 '09 at 23:26

Your Answer


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.