Questions tagged [split]
277 questions
200
votes
9 answers
Split string by delimiter and get N-th element
I have a string:
one_two_three_four_five
I need to save in a variable A value two and in variable B value fourfrom the above string
I am using ksh.
Alex
- 2,255
- 3
- 17
- 12
121
votes
6 answers
What's the best way to join files again after splitting them?
If I have a large file and need to split it into 100 megabyte chunks I will do
split -b 100m myImage.iso
That usually give me something like
xaa
xab
xac
xad
And to get them back together I have been using
cat x* > myImage.iso
Seems like there…
cwd
- 44,479
- 71
- 146
- 167
94
votes
5 answers
Splitting string by the first occurrence of a delimiter
I have a string in the next format
id;some text here with possible ; inside
and want to split it to 2 strings by first occurrence of the ;. So, it should be: id and some text here with possible ; inside
I know how to split the string (for instance,…
gakhov
- 1,095
- 2
- 8
- 9
75
votes
2 answers
Break a large file into smaller pieces
How do I break a large, +4GB file into smaller files of about 500MB each.
And how do I re-assemble them again to get the original file?
Stefan
- 24,830
- 40
- 98
- 126
57
votes
3 answers
Split a file by line and have control over resulting files extension
There is a standard command for file splitting - split.
For example, if I want to split a words file in several chunks of 10000 lines, I can use:
split -dl 10000 words wrd
It would generate several files of the form wrd.01, wrd.02 and so on.
But I…
Rogach
- 6,150
- 11
- 38
- 41
45
votes
4 answers
How to split an image vertically using the command line?
Say I have a large 800x5000 image; how would I split that into 5 separate images with dimensions 800x1000 using the command line?
shley
- 1,081
- 1
- 8
- 7
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
25
votes
5 answers
Splitting text files based on a regular expression
I have a text file which I want to split into 64 unequal parts, according to the 64 hexagrams of the Yi Jing. Since the passage for each hexagram begins with some digit(s), a period, and two newlines, the regex should be pretty easy to write.
But…
ixtmixilix
- 13,040
- 27
- 82
- 118
24
votes
17 answers
Bash script: split word on each letter
How can I split a word's letters, with each letter in a separate line?
For example, given "StackOver"
I would like to see
S
t
a
c
k
O
v
e
r
I'm new to bash so I have no clue where to start.
Sijaan Hallak
- 499
- 1
- 7
- 14
19
votes
4 answers
Extract data from a file and place in different files based on one column value
We will generate a csv file with below values
yp1234,577,1,3
yp5678,577,3,5
yp9012,132,8,9
I need to extract data and create files based on second column. If it's 577 then the whole line has to be extracted and placed in a separate file.
I mean I…
user3116123
- 539
- 1
- 6
- 11
17
votes
6 answers
split file into two parts, at a pattern
How to split a large file into two parts, at a pattern?
Given an example file.txt:
ABC
EFG
XYZ
HIJ
KNL
I want to split this file at XYZ such that file1 contains lines up-to XYZ and rest of the lines in file2.
d.putto
- 303
- 1
- 2
- 7
16
votes
5 answers
How to split a file by using keyword boundaries
I have a vcf file that contains numerous vcards.
When importing the vcf file to outlook it seems to only import the first vcard.
Hence I want to split them up.
Given that a vcard starts with
BEGIN:VCARD
and ends with
END:VCARD
What is the best way…
denormalizer
- 365
- 2
- 4
- 14
16
votes
3 answers
Split file into multiple small files, separate by the newline symbol
Is there a utility that split file by newline symbol? e.g if a file contains the following lines,
aa
bbb
cccc
If I want to split it to 3 files, the desired output would be:
aa, bbb And cccc (in 3 different files)
I already checked the split…
daisy
- 53,527
- 78
- 236
- 383
16
votes
1 answer
Splitting a small file into 512 byte segments changes it, but splitting it in 1k segments doesn't
So I'm trying to split a 64MB file FileCarve.001 into 512 byte segments (each block is 512 bytes long). I need to make sure the file has the same data when split into smaller files, so I cat all the files to standard out and pipe it into sha256sum…
FlashDaggerX
- 171
- 6
16
votes
4 answers
Split: how to split into different percentages?
How can I split a text file into 70% and 30% using the split command ?
aneuryzm
- 1,875
- 4
- 18
- 18