Questions tagged [csplit]

For questions pertaining csplit, a utility that split files based on context.

Split files based on context.

External reference

csplit specification ( The Open Group Base Specifications Issue 7, 2018 edition)

19 questions
43
votes
4 answers

Split a file into two

I have a big file and need to split into two files. Suppose in the first file the 1000 lines should be selected and put into another file and delete those lines in the first file. I tried using split but it is creating multiple chunks.
Aravind
  • 1,559
  • 9
  • 31
  • 44
7
votes
3 answers

Exclude delimiter with csplit

Is it possible to remove the delimiter with csplit? Example: $ cat in abc --- def --- ghi $ csplit -q in /-/ '{*}' $ ls x* xx00 xx01 xx02 $ head xx* ==> xx00 <== abc ==> xx01 <== --- def ==> xx02 <== --- ghi Instead of what it did, i.e. split…
levant pied
  • 231
  • 1
  • 7
5
votes
2 answers

csplit not recognizing provided regexp

I'm working on this big file (DATA.DAT, ~900MB) which contains several other files. It's from a PS2 game. Sound samples (which are in .AIFF format), precisely what I'm after, make up most of its size. After searching the web for PS2 .DAT extractors…
João
  • 53
  • 3
4
votes
2 answers

How to split a file into multiple file after N appearence of a pattern?

I have a file on Linux, containing the coordinates of thousands of molecules. Each molecule starts with a line containing always the same pattern: @MOLECULE And then continues with other lines. I would like to split the file into multiple…
ginopino
  • 370
  • 2
  • 10
4
votes
4 answers

text processing rows to columns for a block

I have a file containing lists on Solaris: List A hi hello hw r u List B Hi Yes List C Hello I need to transpose the lists as shown below: List A List B List C hi Hi Hello hello Yes hw r u How can I do this on Solaris?
John
  • 51
  • 4
3
votes
1 answer

csplit regex with pipe (|)

i want to split file by regular expression, i have file format as below 0|t| lorem ... some text 138|t| title some text if i execute egrep "[0-9]+\|t\|" file | wc -l it counts occurrence correctly but if i execute csplit filename /[0-9]+\|t\|/…
2
votes
1 answer

How do I use modern coreutils on Mac?

How do I get modern coreutils on mac? I ran into this problem using csplit: foo.txt: foo 1 foo 2 foo 3 $: csplit foo '^foo$' '{*}' # error Double checking the manpage, man csplit, csplit on Mac is the FreeBSD version and does not offer the '{*}'…
Chris
  • 894
  • 5
  • 18
2
votes
3 answers

csplit multiple files into multiple files

folks- I'm a bit stumped, on this one. I'm trying to write a bash script that will use csplit to take multiple input files and split them according to the same pattern. (For context: I have multiple TeX files with questions in them, separated by the…
Wayne
  • 25
  • 6
2
votes
1 answer

Bash - extract an indented code block into new file

I have a bunch of LilyPond files in the following format: \score { \new StaffGroup = "" \with { instrumentName = \markup { \bold \huge \larger "1." } } << \new Staff = "celloI" \with { midiInstrument = #"cello" } \relative c { …
nath
  • 5,430
  • 9
  • 45
  • 87
2
votes
2 answers

How to split a file based on context?

I have some files that contain the results of the lldpneighbors command from all our servers. I would like to split these files into individual files for each server in order to make it easier to import this data into our inventory system. Sample…
jesse_b
  • 35,934
  • 12
  • 91
  • 140
2
votes
1 answer

Split a text file into multiple files, beyond the {99} limit of csplit

I'd like to split the contents of a .txt file into multiple files, but I'm encountering two questions about limitations of csplit: (1) can anyone offer a way around csplit's maximum limit of '99' file splits? I have a file with up to 384 splits…
kehmsen
  • 49
  • 1
  • 2
1
vote
2 answers

Divide a fasta file with scaffolds into same lenght files respecting the scaffold ID and the sequence

I am currently working with a large fasta file (3.7GB) that has scaffolds in it. Each scaffold has a unique identifier that starts with > on the first line and on the consecutive line it has the DNA sequence like…
1
vote
1 answer

alternative to csplit - splitting after the pattern

I want to split a file after a delimiter, not before the delimiter, which is what csplit does. I can't find anything anywhere! (Also, why would there be a tool that specifically splits before a pattern, but not one that splits after…
LizzAlice
  • 113
  • 4
1
vote
2 answers

Select the contents respective to some specific content from a file and move it to an output file

I have a file tnsnames.ora and its contents are as below. NEWDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = linuxerp.de.mph.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = linuxerp.de.mph.com)(PORT = 1550)) (CONNECT_DATA…
sabarish jackson
  • 588
  • 3
  • 14
  • 30
0
votes
1 answer

using csplit to split a file based on a regular expression to multiple files

I have a text file that has the contents of the example below, and I would like to split the file to multiple files. [TXT] /path/to/[TXT] [BAT] /path/to/[BAT] [TXT] /path/to/blah/[TXT] [BAT] /path/to/blah/[BAT] So I have figured out I can…
AeroMaxx
  • 189
  • 1
  • 11
1
2