Web Hosting Talk







View Full Version : Splitting files to 001, 002, etc.


Mans
06-24-2005, 08:38 PM
Hi,

The split command splits a file and gives the resulting files aaa, aab, aac, ... suffix. Is there a way to make it using numerical suffix instead, e.g. 001, 002, ... ?

If that is not possible, then how can I use the standard commands, e.g. tar, cpio, cat, gzip, etc. to achieve my goal? I cannot install any external program or script.

TIA.

Burhan
06-25-2005, 02:29 AM
You need to use csplit for this.

Example : split foo.txt into files that contain 10 lines each (assuming foo.txt has 100 lines), naming the files file_00, file_01, etc.

csplit -ks -f file_ foo.txt 10 {10}

Mans
06-25-2005, 03:26 AM
Thank you.

But does csplit work with binary files?

dgeorge
06-27-2005, 02:38 PM
Fsplit

Splits binary files into several pieces. By default, the pieces are conveniently floppy-sized.