This is an almost identical question to split file into two parts, at a pattern but instead of having the lines up to XYZ in
file1 in the example
ABC EFG XYZ HIJ KNL
I want to have the XYZ included in
XYZ is still the pattern to divide on). What I have now is using this answer: https://unix.stackexchange.com/a/202516/108861 and then adding the last line from
file1 to the top of
file2 and removing it from
file1, but is there an easier one-line solution?