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
1
vote
2 answers
split file after a match at the end of the file and keep the match inside file unix
i have a file that contains random lines and key words END:
line 1
line 2
...
line 23
END
line 25
....
line 40
END
and i want to split it into multiple files based on the key word END and have it inside each file as:
file 1
line 1
line 2
...
line…

Mathew Linton
- 33
- 1
- 2
- 8
1
vote
0 answers
Is there a way to make split / csplit work on linux system with columns that have newline in them?
I'm facing issues when trying to split larger files into bunch of smaller ones where one column has new lines in them. In the CSV file that I'm trying to split, it has delimiters that are pipes (|) and each row is separated by newline (\n). Since 1…

Nurdin Ibrisimovic
- 11
- 1
1
vote
2 answers
Split string into multiple rows by capital letters with cSplit
I have survey data. Some questions allowed for multiple answers. In my data, the different answers are separated by a comma. I want to add a new row in the dataframe for each choice. So I have something like this:
survey$q1 <- c("I like this", "I…

Antonio
- 158
- 1
- 14
1
vote
1 answer
Pipe output to zipped tar after cspilt
So, I have the following situation:
A code which produces a large (must be zipped) set of outputs as follows:
line00
line01
...
line0N
.
line10
line11
...
line1M
.
...
I generate this content and zip it with:
./my_cmd | gzip -9 >…

Chris
- 28,822
- 27
- 83
- 158
1
vote
1 answer
Merge and split, using csplit in bash
I'm merging three three files (ls -l):
-rw-rw-r-- 1 kacper kacper 1839510 sie 13 14:27 A.jpg
-rw-rw-r-- 1 kacper kacper 2014809 sie 13 14:27 B.jpg
-rw-rw-r-- 1 kacper kacper 1277047 sie 13 14:27 C.pdf
into one file (merged) in bash using:
cat A.jpg…

kacper
- 75
- 4
1
vote
2 answers
cSplit Coerces Unnecessary NA Row
I have a large data set a small sample of which looks like the 4 x 5 tibble below. I'm trying to split multiple delimited columns into unique rows using variable c=="Split" as below:
library(splitstackshape)
dt <- tibble(
a = c("Quartz | White…

1984
- 41
- 3
1
vote
2 answers
cSplit does not work when a field has embedded the separator
I am using cSplit to split a column into three separate columns. The separator is " / "
However, one of my fields has embedded the "/" separator. The third element of the third line was supposed to be and stay as "f/j" after the split.
When I…

TCS
- 127
- 1
- 11
1
vote
2 answers
Splitting of Big File into Smaller Chunks in Shell Scripting
I need to split the bigger file into smaller chunks based on the last occurrence of the pattern in the bigger file using shell script. For eg.
Sample.txt ( File will be sorted based on the third field on which pattern to be searched )
NORTH…

Katchy
- 85
- 1
- 10
1
vote
2 answers
csplit prefix as file context
I wrote a bash script in order to split a file. The file looks like this:
@MOLECULE
ZINC32514653
....
....
@MOLECULE
ZINC982347645
....
....
Here is the script I wrote:
#!/bin/bash
#split the file into files named xx##.mol2
csplit…

ta8
- 313
- 3
- 12
1
vote
2 answers
How to split big sql dump file into small chunks and maintain each record in origin files despite later other records deletions
Here's what I want to do with (MySQL example):
dumping only structure - structure.sql
dumping all table data - data.sql
spliting data.sql and putting each table data info seperate files - table1.sql, table2, sql, table3.sql ... tablen.sql…

Piotr Osipa
- 55
- 1
- 8
1
vote
1 answer
Splitting a file on Hadoop
I have an 8.8G file on the hadoop cluster that I'm trying to extract certain lines for testing purpose.
Seeing that Apache Hadoop 2.6.0 have no split command, how am I able to do it without having to download the file.
If the file was on a linux…

Leb
- 15,483
- 10
- 56
- 75
1
vote
2 answers
Split file by extracting lines between two keywords
I have a file with the following lines:
string
string
string
MODEL 1
.
.
.
TER
string
string
string
MODEL 2
.
.
.
TER
where there are 5000 such MODELs. I want to split this file such that each section beginning MODEL X and ending TER (shown with…

sodiumnitrate
- 2,899
- 6
- 30
- 49
1
vote
1 answer
shell : csplit command
i'am trying to use csplit command on a file of 700 Mo.
I would like to split the file into 30 smallers files and also respect the tag name i use to start a new file.
1
2
3…

iceman225
- 109
- 1
- 2
- 9
1
vote
1 answer
How to use csplit command to split a log file by day?
I have a log file like bellow:
Jan 01 This the log of this day.
Jan 01 This the log of this day.
Jan 01 This the log of this day.
Jan 01 This the log of this day.
Jan 01 This the log of this day.
Jan 01 This the log of this day.
Jan 01 This…

leo
- 583
- 2
- 7
- 20
1
vote
3 answers
Optimal way to split huge file
I am trying to split a huge text file (~500 million lines of text) which is pretty regular and looks like this:
-- Start ---
blah blah
-- End --
-- Start --
blah blah
-- End --
...
where ... implies a repeating pattern and "blah blah" is of…

Tayyar R
- 655
- 6
- 22