Results 1 to 10 of 13
hi friends,
i need some clarifications in "SPLIT" command.... hope all are know this command is used to split the specified file in the specified size.... i want to split ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 06-24-2009 #1Just Joined!
- Join Date
- Feb 2009
- Posts
- 44
split command: need some help
hi friends,
i need some clarifications in "SPLIT" command.... hope all are know this command is used to split the specified file in the specified size.... i want to split a video file of size 300 MB into 3 parts of size 100 MB each.... wat s d split command i ve to use
- 06-24-2009 #2forum.guy
- Join Date
- May 2004
- Location
- arch linux
- Posts
- 18,733
Check this man page for detailed instructions and options for splitting your file:
Linux Command Directory: splitoz
- 06-24-2009 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,148
The problem with the split command is that it is intended for text files, such as logs. Myself, I usually use the Windows QuickPar 0.9.1 under Wine for splitting files. It also generates recovery par files which can go along with the file parts to reconstitute the original file. Another tool is rar of which there is a Linux version that works quite well.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-24-2009 #4Just Joined!
- Join Date
- Feb 2009
- Posts
- 44
rar is available in linux also va... but whenever i try 2 open a rar file it shows a error message"Archive type not supported"
- 06-24-2009 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,148
What version of rar are you running? Also, how are you invoking it? Since you are using it to create an archive, you should not be getting this error.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-24-2009 #6Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,148
BTW, here is the source code for a binary file splitter I wrote for my personal tool box a long time ago. I just compiled and ran it on my CentOS linux system without any problems. Save it to a file named bsplit.c and to build it, go to the directory you save the file in and execute the command: make bsplit
Code:#include <stdio.h> #include <errno.h> #include <limits.h> #include <malloc.h> void usage( void ) { fprintf(stderr, "usage: bsplit -i<fname> -o<root> [-s<size>]\n" " -i<fname>: input file name\n" " -o<root>: output segment root name\n" " -s<size>: maximum size of each output segment\n"); } /* Returns errno */ int split_file( const char* ifname, const char* ofroot, unsigned int segsize ) { char ofname[PATH_MAX + 1]; FILE *ifp, *ofp; unsigned segnum = 0; size_t bytes_read; size_t bytes_written; void* iobuffer; int retval = 0; iobuffer = (void*)malloc((size_t)segsize); if (iobuffer == NULL) { retval = ENOMEM; } ifp = fopen(ifname, "r"); if (ifp == NULL) { return errno; } do { errno = retval = 0; sprintf(ofname, "%s.%u", ofroot, segnum); ofp = fopen(ofname, "w"); if (ofp == NULL) { retval = errno; } else { bytes_read = fread(iobuffer, (size_t)1, (size_t)segsize, ifp); if (errno) { retval = errno; } else if (bytes_read > 0) { bytes_written = fwrite(iobuffer, (size_t)1, bytes_read, ofp); retval = errno; } } fclose(ofp); ++segnum; } while (!retval && !feof(ifp)); fclose(ifp); return retval; } int main( int argc, const char** argv ) { const char* ifname = NULL; const char* ofroot = NULL; int segsize = -1; int i; if (argc < 3 || argc > 4) { usage(); return -1; } for (i = 1; i < argc; i++) { if (strncmp(argv[i], "-i", 2) == 0) { if (ifname != NULL) { usage(); return 1; } ifname = argv[i] + 2; } else if (strncmp(argv[i], "-o", 2) == 0) { if (ofroot != NULL) { usage(); return 2; } ofroot = argv[i] + 2; } else if (strncmp(argv[i], "-s", 2) == 0) { if (segsize != -1) { usage(); return 3; } segsize = atoi(argv[i] + 2); } else { usage(); return 4; } } if (segsize <= 0) { segsize = 65535; } i = split_file( ifname, ofroot, (unsigned int)segsize ); if (i) { fprintf(stderr, "bsplit: errno %d: %s\n", i, strerror(i)); } return i; }Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-27-2009 #7Just Joined!
- Join Date
- Feb 2009
- Posts
- 44
thanks a lot
- 06-27-2009 #8Linux User
- Join Date
- Aug 2006
- Posts
- 458
- 06-29-2009 #9Just Joined!
- Join Date
- Feb 2009
- Posts
- 44
we cant use it for multimedia files ah
- 06-29-2009 #10Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,148
My bsplit command will work on multimedia files, or any binary data. That's what I wrote it to do. You can simply cat the parts back together as necessary and you will get the original file back.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote

