LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 02-25-2006, 04:25 PM   #1
collern2
LQ Newbie
 
Registered: Mar 2005
Posts: 24

Rep: Reputation: 15
Sed functionality


I have a few xml files and I want to input say 5 parameters within each file. is it possible to do so with sed?



<parameter>A</parameter>

<parameter>B</parameter>

....
....

And so on.

These parameters are meant to go in just inside:
<?xml version="1.0" encoding="utf-8"?>
<config xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">

of each file? Any ideas?
 
Old 02-25-2006, 10:56 PM   #2
collern2
LQ Newbie
 
Registered: Mar 2005
Posts: 24

Original Poster
Rep: Reputation: 15
Just after:
<?xml version="1.0" encoding="utf-8"?>
<config xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">

Awk or sed, it doesn't really matter. Newbie here
 
Old 03-27-2006, 02:13 AM   #3
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
If you just want to extract your parameters with sed, try this:
$ sed -n 's/<par>\(.*\)<\/par>/\1/p' f1
In my experiment `f1' looks like
<par>A</par>
<par>B</par>

Note that this doesn't work if <par> and </par> on different lines.
 
Old 03-31-2006, 12:49 AM   #4
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
Use "cat file | tr '\n \t' ' ' | sed ... " command to convert file to one big line.
 
  


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
Clipboard Functionality f1dreamer Linux - General 3 04-18-2005 01:46 PM
sed and escaping & in something like: echo $y | sed 's/&/_/g' prx Programming 7 02-03-2005 11:00 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM
L.E.A.P. functionality in linux (as in, what is it?) tcaptain Linux - Wireless Networking 5 12-11-2003 04:19 PM
ISDN functionality velska Red Hat 0 09-01-2003 07:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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