Split a text file into multiple text files?

I have a text file with entries like

 1186
 5556
 90844
 7873

 7722
 12
 7890.6
 78.52
 6679
 
 3455
 9867
 1127
 5642

..N so many records like this.

I want to split this file into multiple files like cluster1.txt, cluster2.txt, cluster3.txt, ..... clusterN.txt.

cluster1.txt should be like:

 1186
 5556
 90844
 7873

cluster2.txt should be like:

 7722
 12
 7890.6
 78.52
 6679

..... so on. ..

$ awk '{print $0 > "cluster"NR".txt"}' FS="\n+" RS= infile
1 Like

That space between block 2 and 3 hoses zaxxon's fine proposal... plus - I'm not sure what the FS is for.

1 Like

zaxxon rocked... it worked for me :slight_smile:

awk '{print> "cluster"NR".txt"}' FS="\n+" RS= infile