LinuxQuestions.org
Help answer threads with 0 replies.
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 01-03-2008, 12:38 PM   #1
saphil
LQ Newbie
 
Registered: Aug 2006
Location: Atlanta
Distribution: Ubuntu, Fedora, CEntOS, Linux Mint, PCLinux, AntiX, others
Posts: 11

Rep: Reputation: 2
Simple find&replace across 100 files


I am not a newbie, exactly, as I have been blowing up Linux boxes for about 5 years. I have even been running alpha-testing of ubuntu flights for a while, but I have never had to do any real awk or sed programming and so I find myself in an odd place. I am finding various posts about how to escape control characters but this just distracts me from exactly how (starting from exactly where in a path one would do this) one would do a simple find and replace of a string bill@noranthon.com with wolf@noranthon2.com. If it takes too awfully long to figure it out, I will just wait until my Intro to Linux Programming book arrives, and open each file in kAte and do all the replacements serially.

Thanks for your help.
(No I don't know how to do it in DOS either) lol

-saphil
 
Old 01-03-2008, 01:03 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Escaping a character just means that you are explicitly saying "don't treat this character as a special character". sed and various other tools use regular expressions, which define various special characters.

The only special character in the email address which you want to replace is the period character (.), which means "any character". To escape it, and treat it like a literal period character, just prefix it with a backslash. You only need to escape the period character in the search pattern - not the replacement string.

Here's how you would do the replacement in all files whose name ends in ".txt" in the present working directory:
Code:
sed -i 's/bill@noranthon\.com/wolf@noranthon2.com/g' *.txt
warning: this command will modify files in which the pattern is found.
 
Old 01-03-2008, 01:21 PM   #3
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 542

Rep: Reputation: 33
opps, never mind.
 
  


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
Find 100 largest files in folder tree tyreth Linux - General 2 02-07-2006 09:18 AM
Find & Replace Carriage Return in ooo linuxian Linux - Software 1 04-09-2005 06:43 PM
simple search and replace accross files/direcotries podollb Linux - Software 3 06-04-2004 09:30 PM
Find & Replace Benr Linux - Newbie 5 05-03-2004 03:37 PM
find and replace in files from command line dexter_modem Linux - General 4 06-10-2003 12:27 PM


All times are GMT -5. The time now is 01:03 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