How can I split a text file in two parts at the first occurrence of a specified string? I looked at the split command, but it doesn't do that.
In the past I have used a script to do this. But it is not very efficient, and I have to move the script to different systems. I was wondering if there was a better way to achieve this.
May I recommend the use of csplit (context split), a la:
csplit [options] file PATTERN
For example, let's take a file filename containing
with the command csplit filename /four/
we get file xx00 with
and file xx01 with
More detail can be found at http://docstore.mik.ua/orelly/unix/upt/ch35_10.htm and also at https://davidlyness.com/post/the-functional-and-performance-differences-of-sed-awk-and-other-unix-parsing-utilities