09-17-2009
copy/paste with awk
Hi everybody,
I have two XML files.
I am working on a script that could copy and paste the contents of the first xml file to the desired location in the second xml file.
Here is my first XML file.
Quote:
<Signal xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
XML Schema" xsi:type="ModulatedSignal">
<Name>P+</Name>
<UID>9a4MvZXb2UWM99drxGUxAg==</UID>
<ModulationFreq>55555</ModulationFreq>
<Lengths>
<double>0.21425</double>
<double>0.43574999999999997</double>
<double>0.32475</double>
<double>0.31925</double>
<double>0.22075</double>
<double>0.10625</double>
<double>0.545</double>
<double>0.64825</double>
<double>0.20975</double>
</Lengths> <SigData>AAEAAgMEBQYABAAEAAQDAgUHBX8AAQgCAwQFBggECAIFBAMCBQcFfw==</SigData>
<NoRepeats>2</NoRepeats>
<IntraSigPause>92.769</IntraSigPause>
<ToggleData/>
</Signal>
This is the second XML file.
Quote:
<?xml version="1.0" encoding="utf-8"?><SchedulerState xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
XML Schema">
<Actions/>
<Macros>
<Macro>
<Pause>250</Pause>
<Position>0</Position>
<Name>New Macro</Name>
<MacroActions>
<MacroAction xsi:type="SignalAction">
<Pause>250</Pause>
<Position>0</Position>
<IROutputLocation xsi:type="RedRat3LocationInfo">
<Description>tested RedRat</Description>
<Name>changement_location</Name>
<SerialNo>2329</SerialNo>
</IROutputLocation>
<DeviceName>Premiere</DeviceName>
The contents of the first file have to appear here.
</MacroAction>
</MacroActions>
</Macro>
</Macros>
</SchedulerState>
Finaly, I wnat to obtain something like that :
Quote:
<?xml version="1.0" encoding="utf-8"?><SchedulerState xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
http://www.w3.org/2001/XMLSchema">
<Actions/>
<Macros>
<Macro>
<Pause>250</Pause>
<Position>0</Position>
<Name>New Macro</Name>
<MacroActions>
<MacroAction xsi:type="SignalAction">
<Pause>250</Pause>
<Position>0</Position>
<IROutputLocation xsi:type="RedRat3LocationInfo">
<Description>tested RedRat</Description>
<Name>changement_location</Name>
<SerialNo>2329</SerialNo>
</IROutputLocation>
<DeviceName>Premiere</DeviceName>
<Signal xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="ModulatedSignal">
<Name>P+</Name>
<UID>9a4MvZXb2UWM99drxGUxAg==</UID>
<ModulationFreq>55555</ModulationFreq>
<Lengths>
<double>0.21425</double>
<double>0.43574999999999997</double>
<double>0.32475</double>
<double>0.31925</double>
<double>0.22075</double>
<double>0.10625</double>
<double>0.545</double>
<double>0.64825</double>
<double>0.20975</double>
</Lengths> <SigData>AAEAAgMEBQYABAAEAAQDAgUHBX8AAQgCAwQFBggECAIFBAMCBQcFfw==</SigData>
<NoRepeats>2</NoRepeats>
<IntraSigPause>92.769</IntraSigPause>
<ToggleData/>
</Signal>
</MacroAction>
</MacroActions>
</Macro>
</Macros>
</SchedulerState>
I think it is possible with awk but another solution will do it too.
Thanks, Ludo
10 More Discussions You Might Find Interesting
1. UNIX Desktop Questions & Answers
One of the things that I have learned to take for granted in the Win32 world is the cut, copy and paste hotkeys of ^X, ^C and ^V.
I use these keys all the time under Win32 to copy and paste information from one GUI into another GUI.
My question is, does X have a similiar standard?
... (4 Replies)
Discussion started by: auswipe
4 Replies
2. UNIX for Dummies Questions & Answers
Hi all!
How do I cut, copy and paste under unix??? (2 Replies)
Discussion started by: aitor314
2 Replies
3. Shell Programming and Scripting
Can i search in a file for more than one string at a time? And copy the next string after that and paste it in column style? Is it possible? Thanks! (4 Replies)
Discussion started by: kingpeejay
4 Replies
4. Shell Programming and Scripting
Hi all,
I'm a unix newb andI'm trying to write a script that can copy some text paste it in a certian place and then add a number. It's not really clear but I'll show an example.
what the file looks like right now:
Linux 2.6.24-24-generic (abc) 07/15/09
23:25:01 CPU ... (6 Replies)
Discussion started by: the1hand3r
6 Replies
5. Shell Programming and Scripting
Hello,
I have this path and file:
/dir/dir/dir/dir/dir/dir/dir/dir/dir/THIS_SPOT/fle.txt
I want to end up with:
/dir/dir/dir/dir/dir/dir/dir/dir/dir/THIS_SPOT/fle.txtTHIS_SPOT
Take the dir after the 10th slash, add a tab at the end and paste the dir it copied.
Thanks (4 Replies)
Discussion started by: crowman
4 Replies
6. UNIX for Dummies Questions & Answers
I'm having a problem copy/pasting from a txt file in windows to vi. What happens is I copy a chunk of text, go to the putty terminal, go into insert mode, and right click, and it will stop pasting at a random point and freeze up. Nothing I do gets out of it.
This only happens on my account... (1 Reply)
Discussion started by: solidarity
1 Replies
7. UNIX for Dummies Questions & Answers
Dear All,
I have a file containing 12 lines.
First 3 lines have 9 values and the remaining 9 lines with no values. I was trying to copy and paste these 9 values of the first 3 lines into last 9 lines simultaneously as A=1.491331, B=1.539000 ..... but I don't know how to cope with this... (9 Replies)
Discussion started by: sullah
9 Replies
8. Shell Programming and Scripting
Hello,
I am quite new to shell scripting so don't know all the tools available. What I'm trying to do is open a file optimal.txt search for objectiveValue and copy the number in quotes next to it.
e.g.
...
solutionName="incumbent"
solutionIndex="-1"
objectiveValue="13246"
... (6 Replies)
Discussion started by: StephanR
6 Replies
9. Shell Programming and Scripting
I have one mainframe copy book where I want to copy n times depend on occurs which mention below.
Example:
Below highlighted row mention “occurs 2 times” so I need to copy 2 times till next label 10.
C14992 10 FILLER PIC X(2835).
01 ... (7 Replies)
Discussion started by: srivalli
7 Replies
10. Shell Programming and Scripting
I have rrd file which is have the gaps and I want to fill it out with some value , I've got 10 NaN record and I try to populate data from 10 records be for NaN to change instead of NaN :(
<!-- 2016-05-19 14:10:00 CST / 1463638200 -->... (11 Replies)
Discussion started by: boobytrap
11 Replies