?
Solved

find and replace

Posted on 2009-04-26
3
Medium Priority
?
180 Views
Last Modified: 2013-12-16
Hi All

I want to search the whole filesystem for nobody@noreply.com and replace it with another email address.

Any ideas on how to do this?
0
Comment
Question by:willa666
  • 2
3 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 24235103
find / -type f -exec grep -l 'nobody@noreply.com' {} \; | xargs -i sed -i 's/nobody@noreply.com/another@email.address/' {}
0
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 24235105
might be easier to read as a code snippet
find / -type f -exec grep -l 'nobody@noreply.com' {} \; | xargs -i sed -i 's/nobody@noreply.com/another@email.address/' {}

Open in new window

0
 
LVL 1

Author Comment

by:willa666
ID: 24235231
Hi Tintin

Kewl and if i want to limit the search replace to a certain directory i can just do

 find /var/www/vhosts/ -type f....

Tar
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question