Let’s say you got a file containing texts (from 1 to N) separated by a $ How can a slit the file so the end result is N files?
text1 with newlines $
text2 $etc… $
textN
I’m thinking something with awk or sed but is there any available unix app that already perform that kind of task?
Maybe
split -ppattern?Hmm. That may not be exactly what you want. It doesn’t split a line, it only starts a new file when it sees the pattern. And it seems to be supported only on BSD-related systems.
You could use something like:
edit: You might find some inspiration for the
{ ... }part here:http://www.gnu.org/manual/gawk/html_node/Split-Program.html
edit: Thanks to comment from dmckee, but
csplitalso seems to copy the whole line on which the pattern occurs.