LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-27-2008, 02:31 PM   #1
Raghavan_sat
LQ Newbie
 
Registered: May 2008
Posts: 1

Rep: Reputation: 0
Replacing words in a text file


Hi,
I have a text file that has something like
<number="1234" name="abcd">
and also like this
<number1="2342"
name1="dsfgsdgs">

and has some other text in between

I want to change (replace) the number and name values of these. how can i accomplish this
 
Old 05-27-2008, 03:49 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,592

Rep: Reputation: 188Reputation: 188
What programming language are you using?

-----------------
Steve Stites
 
Old 05-27-2008, 04:07 PM   #3
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,103

Rep: Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719
Depends on what you're wanting to use to do it. You can do this with sed fairly easy, with a regex, or with Perl, or with a bash script.

What are you using? And this does sound like homework, too....
 
Old 05-27-2008, 04:11 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
Homework detector beeping---probability 0.7

This will give the complete solution:
http://www.grymoire.com/Unix/Sed.html
 
  


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
Delete text between key words : sed shalomajay Programming 7 05-11-2011 07:22 PM
How to parse text file to a set text column width and output to new text file? jsstevenson Programming 12 04-23-2008 03:36 PM
replacing text of a file on remote system bajaj111 Linux - Software 4 11-07-2006 02:43 AM
replacing text in file kushalkoolwal Programming 17 10-25-2005 06:25 AM
How can I catch some "KEY WORDS" from a text file without opening it? yuzuohong Linux - General 1 06-14-2002 10:27 PM


All times are GMT -5. The time now is 11:47 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration