Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a dev copy of a website set up that has quite a few hardcoded references to its live counterpart.

I would like to replace all occurrences of "www." with "dev." in all files.

I think I can use a combination of grep + sed, but I'm not sure how.

share|improve this question
3  
Lol it's not programing question. It's basic power user skill. –  Maciek Sawicki Mar 8 '10 at 15:52
    
@Maciek: I can buy that! –  Josh K Mar 8 '10 at 17:56
add comment

1 Answer 1

up vote 2 down vote accepted

first try to used sed on one file its sed 's/foo/bar/g' for replacing foo with bar. Then instead of grep i suggest find. Use it to find all files that need changes (*.php, *.html, etc...). Then find have -exec option.

Please make backup of Your project before You start.

share|improve this answer
2  
Use sed 's/foo/bar/g' for a global replace. –  eleven81 Mar 8 '10 at 16:08
    
Thanks. You are 100% right. with out it in only replace only first instance in a line. I edited my answerer. –  Maciek Sawicki Mar 8 '10 at 16:25
    
I'm trying something like this with no success so far: find . -name '*.html' -exec sed 's/www/dev/g' {} \; –  user30063 Mar 9 '10 at 15:12
    
FYI I ended up using: find . -name "*.php" -print | xargs sed -i 's/www\./dev\./g' –  user30063 Mar 9 '10 at 18:55
add comment

Your Answer

 
discard

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