HI All,
I am trying to split a xml using awk. now the issue is i want to skip three lines from the xml file. first two and last one based on pattern. plz some one help. i am new to awk and struggling :wall:
i guess the above two codes are same.... and i am getting wrong output of all displaying twice. u can see the out put in page 1 i posted...:wall: this is breaking my head. plz help.
When you put a pattern on a line by itself without the opening brace for the corresponding action, awk assumes that that's the end of your pattern-action block. So, if the pattern occurs in the input record, that record is printed (the default action). If not, the record is not printed. But, the following action (which was supposed to be for this pattern) gets executed unconditionally. Hence, the double records.
Ohh god even a "{" making this much difference in awk. u guys are genius then. i got the out put with slight issue. i kept three xml files in a folder and run the command as " awk -f script.awk /folderx/*.xml" . below is the output i got. you can see the second and third xml files having "<?xml version="1.0"?>
<notification>" not removed. but </notification> tag got removed in all three files :). how to kick those two lines.....
HI People i used your script and i am getting the first file without any issue. but second xml file i am getting first two lines tag. you can see the abouve our pt i pasted.... thee you can see <xml version 1.0> tag and <notification> tag occuring in second and third file...
I have multiple xml files. each xml file has multiple blocks. Now what i have to do is split all the blocks in each xml file and append it to a main xml file. while spliting each xml file i have to eliminate three lines. sadly i was unable to do that. Any awk expert here plz help me:wall: .
Below is two sample xml files.
HI COrona688,
thanks for this i will try in my environment, i have small doubt can i run the above command as " nawk-f xmlcat.awk .xml" because i dont know how many xml files will flow in that folder. so if i mention file name as foldername/.xml. will this works for all xml files in that folder????
HI CarloM,
yes u r right but i got no response there:(
Yes, thoug you need a space between nawk and -f of course. * should work for all xml files in a folder. Expanding * into multiple filenames is a property of the shell, not of awk, so it should work for most things really.
The only gotcha is that if you have thousands and thousands of them, * will run out of room to cram arguments, since you can only put so many in one line.