Re: splitting a file



Afifov wrote:
How can I split a file into several files each with a fixed size? I recall that on linux there is a command that has a counter for file size
in bytes but cant seem to remember.


Help is appreciated.

As this is comp.lang.c and not some Linux newsgroup, I suggest you get the name of the file to be split, the maximum size S of the parts, fopen() the file in binary mode and then 1) Try to fread() up to S bytes with return of R read bytes 2) Try to open the file for the next part (do you want to overwrite or die on error?) 3) fwrite() R bytes to the current output file, close it. 4) if R<S, terminate. Else continue at 1.

fclose() your source file.
Done.

<OT>Have you tried 'man split'?</OT

Cheers
 Michael
--
E-Mail: Mine is an   /at/ gmx /dot/ de   address.
.



Relevant Pages

  • splitting a file
    ... I recall that on linux there is a command that has a counter for file size ... Prev by Date: ...
    (comp.lang.c)
  • List FS Types
    ... I recall a command which gave output similar to below, but cant remember for ... the life of me what it was. ... It was a single command which listed each file system along ...
    (SunManagers)
  • Re: Re: 1/2 dozenth request over 3-years
    ... Pure Linux command line login, ... available one and it's modem. ... assortment of 16 terminals and old XT's to hook those in. ...
    (Ubuntu)
  • [PATCH 19-rc2] Fix misc .c/.h comment typos
    ... Implements an interface for i2c compatible eeproms to run under linux. ... Changed struct initializer syntax to the currently preferred notation ... ** Packet is an actual packet structure to be filled in with the packet ... -** as the command processore doesn't process the command packet in any way. ...
    (Linux-Kernel)
  • Re: [opensuse] deleting
    ... during the installation of jre 1.5.0 (according to the install ... i'm learning and having fun with my new toy, the command line interface. ... understand and use linux more efficiently. ... /bin/sh is the Bourne Shell. ...
    (SuSE)