LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to split a file using 'split ' without destroying lines? (https://www.linuxquestions.org/questions/linux-software-2/how-to-split-a-file-using-split-without-destroying-lines-4175589750/)

CaptainDerp 09-19-2016 05:14 PM

How to split a file using 'split ' without destroying lines?
 
Im using split to break up a text file into 20 equal chunks.

Code:

split -N 20 somefile.txt
Ok thats fine, but the problem is, split will at some point cut the ending line in half and dump its chopped contents to the next file, meaning, if the last line in a chunk is 'something' well, 'some' might end up being the last line of the new chunk, and 'thing' will be the first line of the next chunk created.

I want split to knock this BS off and stop corrupting my data, and/or somehow preserve each line in one piece.

Does anybody have any constructive ideas how to remedy this problem?

keefaz 09-19-2016 05:27 PM

Code:

split -nl/20 somefile.txt

CaptainDerp 09-19-2016 09:09 PM

You are Fired.
 
Sir, you are fired. that nonsense does not work.

Code:

# split -nl/24 file.txt
split: invalid option -- 'n'
Try `split --help' for more information.


Emerson 09-19-2016 09:13 PM

Your split is fired, my split has -n option.

Sefyir 09-19-2016 09:17 PM

Quote:

Originally Posted by CaptainDerp (Post 5607497)
Sir, you are fired. that nonsense does not work.

Code:

# split -nl/24 file.txt
split: invalid option -- 'n'
Try `split --help' for more information.


This is correct and works as expected.
I'd help more, but your rude behavior isn't appreciated. Good luck "firing" me.

IsaacKuo 09-19-2016 09:19 PM

split -nl/20 somefile.txt

It works for me on Debian 8.

keefaz 09-20-2016 05:08 AM

I use split from GNU coreutils, don't know for other version

https://www.gnu.org/software/coreuti...nvocation.html


All times are GMT -5. The time now is 10:20 AM.