Google Answers Logo
View Question
 
Q: Linux search and replace from command line ( Answered 5 out of 5 stars,   1 Comment )
Question  
Subject: Linux search and replace from command line
Category: Computers > Software
Asked by: davert3-ga
List Price: $15.00
Posted: 08 Aug 2006 13:52 PDT
Expires: 07 Sep 2006 13:52 PDT
Question ID: 753943
I need a Linux command line to search and replace for a string of text
- I have gawk but can't figure it out - it's complicated by the fact
that I have to replace slashes: would like to search for .com// and
replace with .com/ in file sitemap.xml -- help?
Answer  
Subject: Re: Linux search and replace from command line
Answered By: tisme-ga on 08 Aug 2006 16:01 PDT
Rated:5 out of 5 stars
 
Hello davert3-ga,

Try the following: 
sed 's/\.com\/\//\.com\//' file

Let me know if this works for you.

tisme-ga

Clarification of Answer by tisme-ga on 08 Aug 2006 16:02 PDT
In place of 'file' put sitemap.xml as well as a new file right after.

Try this: 

sed 's/\.com\/\//\.com\//' sitemap.xml >sitemap2.xml

Good luck!
davert3-ga rated this answer:5 out of 5 stars
Perfect the first time, thanks!

Comments  
Subject: Re: Linux search and replace from command line
From: bozo99-ga on 08 Aug 2006 16:27 PDT
 
perl -pi -e 's/(\.com\/)\//\1/'  sitemap.xml

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy