The csplit is a Unix command thats split a file into two or more smaller files determined by context lines.
Questions tagged [csplit]
62 questions
10
votes
5 answers
Using regex to tell csplit where to split the file
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…

Philip Meissner
- 163
- 1
- 1
- 10
3
votes
3 answers
Bash how to split file on empty line with awk
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…

Alessandro Solbiati
- 969
- 11
- 23
2
votes
6 answers
Merge columns with multiple delimiters
how can I merge columns with variable number of delimiters so I can obtain something like the output (assuming everything is a character)?
dt1
letter
1 a
2 b+c
3 c
4 d+e+f+g
5 a+g+e
dt2
letter number
1 a 1
2 …

Garn_R
- 77
- 5
2
votes
1 answer
csplit in zsh: splitting file based on pattern
I would like to split the following file based on the pattern ABC:
ABC
4
5
6
ABC
1
2
3
ABC
1
2
3
4
ABC
8
2
3
to get file1:
ABC
4
5
6
file2:
ABC
1
2
3
etc.
Looking at the docs of man csplit: csplit my_file /regex/ {num}.
I can split this file…

vbfh
- 115
- 1
- 8
2
votes
2 answers
Invalid parameters using find and csplit
This should be a simple task ... !
I have a directory with a number of html files. Each one has a div called for a class called crumb. I want to split the file into two on crumb. Later, I'll concatenate the second part of the split file with a new…

AndrewUK
- 31
- 3
2
votes
2 answers
Split massive yaml file into N valid yaml files
I have a big yaml file:
---
foo: bar
baz:
bacon: true
eggs: false
---
goo: car
star:
cheese: true
water: false
---
dog: boxer
food:
turkey: true
moo: cow
---
...
What i'd like to do is split this file into n-number of valid yaml files.…

mootpt
- 298
- 3
- 11
2
votes
1 answer
pipe output of gzip into csplit
This command works:
csplit really_big_file.txt -f ../dump/really_big_file_ /^H\|756\|/ {*}
but this command:
gzip -dc really_big_file.txt.gz | csplit -f ../dump/really_big_file_ /^H\|756\|/ {*}
yields:
csplit: cannot open '/^H|756|/' for reading:…

user189035
- 5,589
- 13
- 52
- 112
2
votes
1 answer
How to split a big mysqldump file for get each structure and data separately?
Based on https://gist.github.com/jasny/1608062#file-mysql_splitdump-sh
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -lt 1 ] ; then
echo…

Nolwennig
- 1,613
- 24
- 29
2
votes
3 answers
Split .json File into Multiple Files on Mac
I'm running on a mac and have a very large .json file with more than 100k objects.
I'd like to split the file into many files (preferably 50-100).
SOURCE FILE
The original .json file is a multidimensional array and looks a bit like this:
[{
…

Brandon
- 1,701
- 3
- 16
- 26
2
votes
1 answer
Can't remove columns from a dataframe, output turns into a logical vector
There seems to be something wrong with the data.frame I get from the cSplit function.
I can't extract columns without NAs from using the code below:
data_places <- data_table[ , colSums(is.na(data_table)) == 0 ]
The output is a Named logi vector…

JnrfL
- 189
- 2
- 8
1
vote
3 answers
Naming csplit files with a specific string inside the file
So, I have a file called "test.log" with multiple entries like this:
2022-09-30T11:37:54 START_TEST_CASE Start 'tst_T01-TC02' Test 'tst_T01-TC02' started (tst_T01-TC02)
2022-09-30T11:38:01 PASS shared/scripts/Project/LoginWindow.py:39:…

Sync
- 11
- 2
1
vote
4 answers
Split file after n number of non consecutivempty lines
I am trying to split a big text files after n number of empty lines. The text file contains exactly one empty line as data separator. Like below:
Lorem ipsum
Lorem ipsum
Lorem ipsum
Lorem ipsum
Lorem ipsum
Lorem ipsum
Lorem ipsum
Lorem…

gmtek
- 741
- 3
- 7
- 25
1
vote
1 answer
How to use csplit to split a file based on every X amount of delimiter matches
I have a 457 MB file and trying to split it down into much smaller file. Here's what's currently working:
csplit -z Scan.nessus /\

LewlSauce
- 5,326
- 8
- 44
- 91
1
vote
2 answers
Splitting large file in two while keeping header
I have a very large text file (ca. 1.8TB) that I need to split at a certain entry. I know which line this entry is on, but I can also identify it via a grep command. I only care about the part of the file from this entry on.
I saw that certain Unix…

Jer Sto
- 73
- 2
- 9
1
vote
2 answers
How do I split a file into multiple file based on a RegEx pattern?
I would like to split a file into multiple files based on a particular regex pattern. I provide a reproducible example below. If there is an easier solution, I would also welcome it!
I have a directory with the following files:
page1.html page2.html…

hy9fesh
- 589
- 2
- 15