0

I have a long text data file structured in time frames, each delimited by a keyword (FLAG here) followed by its number, in this manner :

FLAG
1
... [data for frame 1]
FLAG
2
... [data for frame 2]

The number of lines of each frames is supposed to be fixed, however because of an I/O issue, some of them are shorter. I want to extract each frame to a separate file (frame_1.log, frame_2.log, etc...).

Using sed -n /FLAG/,{p;/^FLAG/q}, I can print the content of the first frame, but is there a clean way to save each one to a new file?

theob
  • 1
  • See https://unix.stackexchange.com/questions/263904/split-file-into-multiple-files-based-on-pattern or https://unix.stackexchange.com/questions/15662/splitting-text-files-based-on-a-regular-expression – Wiktor Stribiżew Dec 02 '21 at 09:03
  • https://unix.stackexchange.com/questions/15662/splitting-text-files-based-on-a-regular-expression – KamilCuk Dec 02 '21 at 09:04
  • Please add your desired output (no description, no images, no links) for that sample input to your question (no comment). – Cyrus Dec 02 '21 at 09:04

0 Answers0