I open up terminal, cd to my working directory and then execute:
awk -f split.awk db.xml
When I execute that, I just get an error saying awk can't find the file.
Again, sorry for being such a beginner -- now that I know AWK exists, I plan to purchase a few books on and dive into how I can apply in my day-to-day programming.
what is the exact output of awk? This seems to happen mostly when there are invisible characters introduced to the awk file during the copy of the text to the .awk file. And make sure all the files are readable and the directory is writable by the account you use to open the terminal window...
awk: can't open file split.awk
source line number 1 source file split.awk
context is
>>> <<<
Do I need to put in a full file path? I've already navigated to the directory within terminal, it's in the same directory as db.xml, which seems to get picked up fine.
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.
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....
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?
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:
awk -f split.awk db.xml
I now get the following error:
awk: illegal statement
input record number 1, file db.xml
source line number 8
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...
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...
I really don't know what's left to try then.. for another test, I used terminal, executed a touch command to create split2.awk and then used TextEdit to retype the code character by character with no tabs and I still have the same exact problem.
Are there any other possible solutions? I never thought it would be this much of a hassle -- again, thank you so much for the help.