The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
multiple smaller files from one large file rtroscianecki UNIX for Dummies Questions & Answers 2 07-15-2009 10:25 PM
Break a file into separate files chiru_h Shell Programming and Scripting 8 07-29-2008 03:06 AM
how to divide single large log file into multiple files. kamleshm Shell Programming and Scripting 1 01-15-2008 07:33 PM
compare two .dat files and if there is any difference pulled into a separate file kirankumar Shell Programming and Scripting 1 04-19-2006 02:13 AM
Need to split a large data file using a Unix script SAIK HP-UX 1 03-29-2006 04:05 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-17-2009
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,420
Quote:
Originally Posted by JRy View Post
When I execute this, I just an exact copy of my original file with the number 1 appended to it, ex: db1.xml, but it's also a 500 MB file.
I can't see where is the problem ... can you elaborate ?

Starting from your original data sample I get:
Code:
# awk '/<ROW/{close("row"c".xml");c++}c{f="row"c".xml";print $0 > f}' file
# ls
file            row1.xml        row2.xml        row3.xml
  #2 (permalink)  
Old 10-17-2009
JRy JRy is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 8
Quote:
Originally Posted by danmero View Post
I can't see where is the problem ... can you elaborate ?

Starting from your original data sample I get:
Code:
# awk '/<ROW/{close("row"c".xml");c++}c{f="row"c".xml";print $0 > f}' file
# ls
file            row1.xml        row2.xml        row3.xml
Ah, I see the issue. If I test with the sample XML I provided in the original post, it works. But it's when I try to execute it on the actual XML export from FileMaker that it fails and just stops after creating one file, which contains all of the < ROW matches.
I think maybe it's because the FileMaker XML export is really crappy and has absolutely no formatting at all, there's no line breaks, no indenting, no nothing, all the instances of the < ROW > </ROW> node are all on the same line.

Would that be an issue and is there a way around it?


Quote:
Originally Posted by jp2542a View Post
what happens if you type the awk command in the window that you used to create the split.awk file? The error message suggests that you don't have read access to the split.awk file in the new terminal window....
Same result, I also verified the standard OS X account (my account + the staff account + everyone) has both read/write access to split.awk.

** UPDATE ** so I tried using the touch command via terminal to create the file split.awk, then edited it's contents via CODA (still using the exact code you provided), and when I run the following command:
Code:
awk -f split.awk db.xml
I now get the following error:
Code:
awk: illegal statement
 input record number 1, file db.xml
 source line number 8

Last edited by JRy; 10-17-2009 at 02:36 AM..
  #3 (permalink)  
Old 10-17-2009
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,420
Quote:
Originally Posted by JRy View Post
I'm using AWK via Terminal in OS X Leopard, I'm not sure how to go about item #1, but for #2 I tried the following:
Code:
awk '/<ROW/{close("row"c".xml");c++}{print $0 > "row"c".xml"}' db.xml
Which produces a syntax error at line 1 when executed
Code:
awk '/<ROW/{close("row"c".xml");c++}c{f="row"c".xml";print $0 > f}' file
  #4 (permalink)  
Old 10-17-2009
jp2542a jp2542a is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 142
what happens if you type the awk command in the window that you used to create the split.awk file? The error message suggests that you don't have read access to the split.awk file in the new terminal window....
  #5 (permalink)  
Old 10-17-2009
jp2542a jp2542a is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 142
The only thing that I can think of is that split.awk contains more than just the script code. Invisible characters? I've tried this on both Centos and a windows (cygwin) system...
  #6 (permalink)  
Old 10-17-2009
JRy JRy is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 8
Quote:
Originally Posted by jp2542a View Post
The only thing that I can think of is that split.awk contains more than just the script code. Invisible characters? I've tried this on both Centos and a windows (cygwin) system...
Here's the exact contents of my file if you want to take a look:
share1t.com File Sharing | Download: split.awk
I still feel like I may be doing something wrong.

Thank you again for your help, I really do appreciate it.
  #7 (permalink)  
Old 10-17-2009
jp2542a jp2542a is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 142
I downloaded the script onto both my my Centos (linux) system and my windows (cygwin) system. It worked fine on my Linux system. On the windows system, there were translation errors. There are hidden characters...
Reply

Bookmarks

Tags
awk, large, xml

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0