Splitting large text file on every blank line

后端 未结 9 936
南方客
南方客 2020-12-05 07:53

I\'m having a bit trouble of splitting a large text file into multiple smaller ones. Syntax of my text file is the following:



        
9条回答
  •  萌比男神i
    2020-12-05 08:45

    awk -v RS="\n\n" '{for (i=1;i<=NR;i++); print > i-1}' file.txt
    

    Sets record separator as blank line, prints each record as a separate file numbered 1, 2, 3, etc. Last file (only) ends in blank line.

提交回复
热议问题