LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-15-2011, 12:50 AM   #16
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 23, 24, RHL 5.2
Posts: 560

Rep: Reputation: 56

Hey, I know it has been solved, but I thought I would join the crowd. It can be done in the vi editor fairly easily.

Code:
:%s/d1.com/d2.com/g
 
Old 02-15-2011, 01:03 AM   #17
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,003

Original Poster
Rep: Reputation: 67
Quote:
Originally Posted by wmakowski View Post
Hey, I know it has been solved, but I thought I would join the crowd. It can be done in the vi editor fairly easily.

Code:
:%s/d1.com/d2.com/g
Thanks for the input. Questions:
1) is your solution case sensitive? Does vi accept an "i" flag?
2) Would it also replace "d1 com" with d2.com? (note the space). Is there any way to escape the period so that it must be d1.com and not d1xcom or d1_com?
3) Does vi bog down when you open the file? I've been able to do some of this stuff in nano but it takes a good long time to open large files sometime and do all the replacements. This db dump is 150MB.
 
Old 02-15-2011, 01:30 AM   #18
micxz
Senior Member
 
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Your right %s/d1.com/d2.com/g is matching things like d12com d1_com. You will need to escape the periods.
Code:
:%s/d1\.com/d2\.com/gi
I think /i works just as well. "bog down" depends on your system Give it a try but I think sed or perl is a better bet.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux command to find and replace string within text file chips11 Linux - Newbie 5 11-24-2008 03:25 PM
Find and replace text in multiple file Bad_Bob Linux - Software 9 05-08-2008 03:31 AM
Need command to search and replace text in file acascianelli AIX 12 04-11-2007 09:16 PM
command line edit -- global find/replace on text file w/o going into vi car182 Linux - Newbie 4 05-25-2006 06:42 PM
help! Script or command needed to replace text in a file. farmerjoe Linux - Newbie 2 01-02-2005 04:07 PM


All times are GMT -5. The time now is 03:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration