i have a file that i need split into multiple files, and need it done via separate start and end delimiters.
for example, if i have the following file:
abcdef
START
ghijklm
nopqrst
END
uvwxyz
START
abcdef
ghijklm
nopqrs
END
START
tuvwxyz
END
i need 3 separate files of:
file1
START
ghijklm
nopqrst
END
file2
START
abcdef
ghijklm
nopqrs
END
file3
START
tuvwxyz
END
i found this link which showed how to do it with a starting delimiter, but i also need an ending delimiter. i have tried this using some regex in the awk command, but am not getting the result that i want. i don't quite understand how to get awk to be 'lazy' or 'non greedy', so that i can get it to pull apart the file correctly.
i really like the awk solution. something similar would be fantastic (i am reposting the solution here so you don't have to click through:
awk '/DELIMITER_HERE/{n++}{print >"out" n ".txt" }' input_file.txt
any help is appreciated.