I have a config file with a bunch of these type of blocks:
<concat destfile="${standard.js.file}" append="true">
<filelist dir="${js.dir}/foo" files="foo.js, foo2.js"/>
<filelist dir="${js.dir}" files="foo3.js"/>
<filelist dir="${js.dir}/bar/js" files="bar.js" />
<!-- misc comment to throw things off a bit -->
<filelist dir="${js.dir}" files="finalfoo.js"/>
</concat>
I need to grab all these files, in the order they are here, and only within this section (the unique factor is the destfile value), and merge them all into a single file, newfoo.js
I already know how to take multiple files and concatenate them with cat file1 file2 > concatfile, but I'm struggling to figure out how to get the files out of the config file, then combine those.
I want the content of the files merged into one, so if the contents of ${js.dir}/foo/foo.js is 'foo' and ${js.dir}/foo/foo2.js contains 'bar', the first part of 'newfoo.js' would be:
foo
bar
and would be followed by the contents of all the other JS files within that <concat> element
---------- Post updated at 07:14 PM ---------- Previous update was at 06:42 PM ----------
To clarify:
I want to take that bit of code in the OP, come back with essentially this:
$jsdir will be defined in the calling script, so it'll look like this:
configfile="config.xml"
jsdir="./js/"
open $configfile
for every filelist between "${standard.js.file}" and "/concat"
files=/dir=\"${js.dir}(.+)\" files=\"(.+)\"/
for each file, prepend $jsdir/
sed $files s/\,// #(remove commas)
cat $files > /finalfoo.js
---------- Post updated at 12:51 AM ---------- Previous update was at 12:18 AM ----------
I'm trying to modify the script for another section (<concat destfile="${standard.css.file}"...) but oddly, even when I change the line on your script from:
/standard.js.file/
to
/standard.css.file/
it's still including the JS block. Is there something else in there that I'm missing?
---------- Post updated at 01:33 AM ---------- Previous update was at 01:04 AM ----------
Figured it out -- the values for standard.css.file and standard.js.file we being set above, so it was finding those in the awk, then using all of the stuff below that -- the JS is the first set, so it was including that.
I just added more specificity, /\{standard\.css\.file/