I have a file containing the following content:
(Item)
(Values)
blabla
blabla
(StopValues)
(Item)
(Values)
hello
hello
(StopValues)
I'd like to split it into multiple files so that one file always has the content from (Item) to (StopValues) (including both of these tags). Also, as I have to further use those files and use mktemp, I'd like to save each filename in an array when creating it.
To split them I used an approach with awk:
awk '/(StopValues)/{n++}{print >"out" n ".txt" }' mainfile.txt
First problem here, when providing 'one set' of data, I still get 2 new txt files, one containing just (StopValues) tag, the other one missing just this tag.
Second problem, I'd like to create files with mktemp instead of naming them myself and I need them in an array, how would I dynamically make new ones in the awk loop and save their name into an array?
cat *.txt | ./scriptand all the content from cat is written in one file. When I pipe the cat of all files like that, would there be a possibility to see which content came from which "cat(ed) file", respectively split it and directly get it as array? Because if thats possible all I try to do is not needed anymore