csplit

Bash how to split file on empty line with awk

不打扰是莪最后的温柔 提交于 2020-12-12 11:37:05
问题 I have a text file ( A.in ) and I want to split it into multiple files. The split should occur everytime an empty line is found. The filenames should be progressive ( A1.in , A2.in , ..) I found this answer that suggests using awk , but I can't make it work with my desired naming convention awk -v RS="" '{print $0 > $1".txt"}' file I also found other answers telling me to use the command csplit -l but I can't make it match empty lines, I tried matching the pattern '' but I am not that

Using csplit to divide a large file in smaller files with a determinated name

蓝咒 提交于 2019-12-11 16:46:19
问题 Having a very large plaint text file, with about 40 million lines, each line with the same length and format, we want to split it, line by line in N files using csplit . For example, if N is 80, the name of the generated files should be: FILE00000001.txt FILE00000002.txt … FILE00000080.txt Note that FILE1.txt, FILE2.txt … FILE80.txt is not valid for us. Thanks! 回答1: The parameter I was looking for is '-n 8'. Next example splits BIG_FILE.txt into 18 files of 5000 lines each of them: csplit -f

Using regex to tell csplit where to split the file

白昼怎懂夜的黑 提交于 2019-11-27 04:46:07
问题 I have a large text file with content set up like this: --- title: Lorim Ipsum Dolar --- Lorim ipsum content --- title: Excelvier whatever --- Lorim ipsum content goes here. I'm trying to split up this file into individual files using csplit . The individual files would have content formatted like this: --- title: Lorim Ipsum Dolar --- Lorim ipsum content I was hoping to be able to regex the ---, newline & title like so ---\ntitle But I'm not able to select it with… csplit -k products.txt '/-