LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-29-2007, 03:03 PM   #1
neocontrol
Member
 
Registered: Jul 2005
Posts: 273

Rep: Reputation: 31
Huge file - need to replace string with something unique


I have a huge file, that contains hundreds of the string _EMAIL_

I need to change that string to be _EMAIL_1 then to _EMAIL_2 then to _EMAIL_3 etc etc etc

I imagine awk would be the best job for this, but I'm not familar enough with it.

Can someone spit out something that increments the replacement word?

I think awk should do this, how would I write it?
awk find the string "_EMAIL_" and then replace with "_EMAIL_"++

Thanks for the help.
 
Old 11-29-2007, 03:18 PM   #2
neocontrol
Member
 
Registered: Jul 2005
Posts: 273

Original Poster
Rep: Reputation: 31
Code:
awk 'Begin {$E="_EMAIL_"}{sub($E, ++$E); print}'
Probably off a bit, as I'm trying to figure out awk in 10 minutes.
 
  


Reply



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
How to replace a string in a text file jpan Linux - General 3 10-14-2012 06:17 PM
how to replace string by other one in a file & without perl ? Xeratul Programming 4 05-25-2007 11:13 PM
select the longest string of each unique path in a sorted text file powah Programming 5 03-01-2007 11:16 AM
BASH: Replace string in file with another eur0dad Programming 5 07-27-2006 04:29 PM
replace a string/number in a text file jpan Linux - General 3 10-22-2004 09:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:34 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
Open Source Consulting | Domain Registration