I'm trying to read an xml file and copy it line by line to another file and want to preserve the tabs.
What i'm trying to do is if I get to a certain line in the xml, I'm going to check to see if the next line is specifically what I want. If it's not, then I want to insert a single line of text right after it.
So I'm thinking I'll read the original xml line by line and copy it over to a temp file. While reading it line by line, if I come across my specific situation, i'll concat that new line to the temp file and continue with the rest of the xml.
hey thanks alot Franklin...major help...thanks, I'm almost there...
I modified the following from you...
what I can't figure out to do is put that value of print in bold to not show up in the results. I need it to do the if statement. But it's also showing up in my ending result.
Any ideas?
This is the current results:
The first two xml does NOT have <letters> after the <?xml tag. The third one does.
As you can see, the script adds <letters> to the first one and two xml's but it also printed out the <GLOBAL> tag since that was what was right after "<?xml"
I'm new with scripting and I can't seem to figure out what I should do to get the output that I want.
My file content would be below.
ID2|ID3 |ID4|ID5 |
I'm trying to replace the field of ID3 which has a fixed length of 10 characters, for each entry I have placed on a .txt file... (5 Replies)
Hi all,
I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like:
<date1>|<data1>|<url1>|<result1>
<date2>|<data2>|<url2>|<result2>
<date3>|<data3>|<url3>|<result3>
<date4>|<data4>|<url4>|<result4>
What I... (3 Replies)
Hi All,
Am trying to write wrapper shell/bash script on a utility tool for which i need to pass 2 files as arugment to execute utility tool.
Wraper script am trying is to do with above metion 2 files.
utility tool accepts :
a. userinfo file : which contains username
b. item file : which... (2 Replies)
Hello,
I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be:
SRVXPAPI001 ERRO JUN24 07:28:34 1775
REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F
... (8 Replies)
Hello Everyone,
I need a help from experts of this community regarding one of the issue that I am facing with shell scripting.
My requirement is to append char's at the end of each line of a file. The char that will be appended is variable and will be passed through command line.
The... (20 Replies)
How would you do vim copy line and paste at the beginning, middle, and end of another line. I know yy copies the whole line and p pastes the whole line, but on its own separate line. Sometimes I would like to copy a line to the beginning, middle, or end of another line. I would think this would be... (3 Replies)
Hi All,
I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
I am using the while-loop to read a file.
The file has lines with null-terminated strings (words, actually.)
What I have by that reading - just a first word up to '\0'!
I need to have whole string up to 'new line' - (LF, 10#10, 16#A)
What I am doing wrong?
#make file 'grb' with... (6 Replies)
Hi gurus Is possible to preserve first line of text and search in another lines ?
the only way that I think is:
ps aux | awk '{if (NR==1) {print $0} else if ($11 ~ /sshd/) {print $0}}'
but is there any more elegant way ? thanks (4 Replies)
Hi
I have a log file (say log.txt). I have to search for a line which has the string ( say ERROR) in the log file and copy 15 lines after this into another file (say error.txt). Can someone give me the code and this has to be in PERL
Thanks in advance
Ammu (3 Replies)