I hope u can help me with the following as well if i may ask.
I have a list of xml files that need to be parsed by a Java parser (from selectbf).
When the files are too big it does not funtion anymore.
So i decided to write a "tiny" "easy" bash-script that would split up the xml-files and make sure all the tags are correct.
Now, on paper it looks pretty good, i've got it all worked out. I only need a piece of code (
My current problem is that i have 3 xml files in a directory :
-rw-r--r-- 1 grave grave 129800403 Mar 1 18:19 ev_14567-20050215_0956.xml
-rw-r--r-- 1 grave grave 4305438 Mar 1 18:19 ev_14567-20050218_2158.xml
-rw-r--r-- 1 grave grave 2109 Mar 1 18:19 voorbeeld_part1.xml
The criterium for a file to be split up into smaller ones is 30 MB. So if it is bigger than 30 MB it needs to be copied to a special directory where the splitting process will take place.
However i can't get my loop in bash working correctly since it moves all the xml-files instead of just the one from 129 mb.
Here is my code :
#This script will (try to) split xml-logfiles from BF1942 into decent, usable ones of 30 mb in size.
#detection of how many xml-files we have that are bigger than 30 MB cause they need to be split up
#how many xmlfiles are in the directory to start with ?
#First we set all variables to zero, just making sure
#here is some room for the ftp-procedure
#lets make a textfile that contains all the xmlfiles, big and small, just to see how many we got
#and echo it out as a check, we can remove or comment this later, right now its usefull for error handling
#how many xml files do we have exactly
number_of_xmlfiles=`wc -l listing.txt|cut -f1 -dl`
# Next we're gonna copy all xml files bigger than 30 mb to a separate (parsing) directory
# However we need to define the xml file that the script is currently looking at :
while [ "$i" -le "$number_of_xmlfiles" ] && [ "$filesize_kb" -gt "$filesize_limit_kb" ];
current_filename=`head -n "$i" listing.txt` # RIGHT HERE IT GOES WRONG
mv "$path_to_all_xmlfiles"/*.xml "$dest_path_big_xmlfiles"/
echo dit lijkt goed te gaan
#filesize_lines=`wc -l |cut -f1 -de` #this is for later on, neglect it for now
I have tried to comment it as good as possible, and the programming might be just a 'bit' crappy, but please if someone can tell me what is wrong with my loop, i'm all ears. The splitting of the files is something i will have to deal with later on. I try to take one step at a time.
If someone has time, please let me know what im doing wrong here.