I have a input file like
foo xxx yyy zzz
foo xxx yyy zzz
foo xxx yyy zzz
foo xxx yyy zzz
bar xxx yyy zzz
bar xxx yyy zzz
foo xxx yyy zzz
..
How to split the input file by line, into foo.txt
and bar.txt
, depending on the existence of foo
and bar
at the beginning of the line?