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-10-2012, 06:41 AM   #1
frambau
Member
 
Registered: Feb 2012
Posts: 32

Rep: Reputation: Disabled
AWK. generate limited files from xml


Hi,

I need to extract the tag content in a xml to a diferent secuentials files. One for each ocurrence of this tag

i use this sentence

H="try_"
awk -v name=$H 'BEGIN {RS = "[<>]"}{file = (name)(++i)".out"; ORS = /description/?"\n":"|"}/item/,/\/item/{if(/^(description)$/ && getline)print > file; close(file) }' inputfile

but i have two problems.
The first is the limit of files created. I can only generate 1000 files.
My second problem in this case is the name. This is not secuential.

ANY HELP PLEASE!!!!
 
Old 02-10-2012, 06:59 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
I don't think you need to close(file)

What is the problem with "only generate 1000 files", are you sure there is more than 1000 <item>.*</item>
in the inputfile ?
 
Old 02-10-2012, 07:00 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Quote:
The first is the limit of files created. I can only generate 1000 files.
Why do you believe this? As an example the following works without issue:
Code:
awk 'BEGIN{while(i++ < 1050)print "in the file" > "file"i}'
I see no reason why you would be limited by awk to create more than 1000 files.

Also, you seem to be creating multiple questions all based on the same information. Is there a reason you are not sticking with your original question?
 
Old 02-10-2012, 07:02 AM   #4
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by grail View Post
Also, you seem to be creating multiple questions all based on the same information. Is there a reason you are not sticking with your original question?
Yes, it gets tedious to follow
 
Old 02-10-2012, 07:09 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by Cedrik View Post
Yes, it gets tedious to follow
I agree. Furthermore the input file is not posted in this thread, therefore we have to look at your posting history to fully understand the question. For this reason I report this thread for merging with your previous one (leaving your very first one alone). Please, refrain from splitting your issue into multiple threads in the future. Thank you.
 
Old 02-10-2012, 07:11 AM   #6
frambau
Member
 
Registered: Feb 2012
Posts: 32

Original Poster
Rep: Reputation: Disabled
Sorry so much. This error is mine


THANKS again.
 
  


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
awk to read an xml file? frenchn00b Linux - General 10 11-01-2011 01:40 PM
generate xml from nmap output shourya21 Linux - Newbie 1 01-24-2008 08:54 AM
RSS XML File to be read and generate HTML page redhatrosh General 10 02-15-2006 02:16 AM
What packages are needed to generate lib-javox-xml-transform-2.4.1.so, etc. satimis Fedora 0 09-25-2004 09:51 AM
Foomatic: How to generate ppd drivers from xml files? johnny1959 Linux - Newbie 0 02-17-2004 04:27 AM

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

All times are GMT -5. The time now is 01:44 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
Open Source Consulting | Domain Registration