Solved

tarring into multiple files

Posted on 1998-12-24
3
254 Views
Last Modified: 2010-04-21
Hi...

Suppose that I have a file of size 20MB...

Is there a way that I can split it into 4 5MB files on a unix machine, and then transfer them onto a windows machine and rejoin the 4 files into 1 file?

Thanks
0
Comment
Question by:applecrusher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Accepted Solution

by:
tangyw earned 100 total points
ID: 2008501
Hi

Assume that
1. There is no LAN between your machines.
2. The file already be compressed. ( Now is binary file ).

So you can do it as follows:
1. Make a program to split your file into smaller size which you wanted.
2. Copy these splited files onto your windows machine.
3. Use DOS command to rejoin them.
   c:copy /b file01+file02+file03+file04 yourfile

Sample program:
#include      <stdio.h>

#define            BUFSIZE            1024
main( argc, argv )
int            argc;
char      **argv;
{
      FILE      *ifp, *ofp;
      char      buffer[BUFSIZE];
      char      FileName[128];
      int            i, FileNum, FileSize, EndFlag;
      long      readn;

      if ( argc < 3 ) {
            printf("Usage: %s filename size(Kbyte)\n", argv[0]);
            exit( 1 );
      }
      if ((ifp=fopen(argv[1],"rb")) == NULL ) {
            printf("File %s open error!\n", argv[1]);
            exit( 2 );
      }
      sscanf( argv[2], " %d", &FileSize );
      FileNum = 1;
      EndFlag = 0;
      while ( !EndFlag ) {
            sprintf(FileName, "%s%02d", argv[1], FileNum );
            if ( (ofp=fopen(FileName, "wb")) == NULL ) {
                  printf("File %s create error!\n", FileName);
                  exit( 3 );
            }
            for ( i=0; i<FileSize; i++ ) {
                  if ((readn=fread(buffer, sizeof(char),BUFSIZE, ifp )) == 0 ) {
                        EndFlag = 1;
                        break;
                  }
                  fwrite(buffer, sizeof(char), readn, ofp );
            }
            fclose( ofp );
            FileNum++;
      }
      fclose( ifp );
}

Have a good holiday!
-Tang
0
 
LVL 1

Expert Comment

by:toTo
ID: 2008502
there is a command named split that already does the job
you can  Split a File Into Multiple Files Containing
a Specified Number of Lines or of Bytes

0
 

Author Comment

by:applecrusher
ID: 2008503
someone gave me a much easier way........

in unix:
split -b5m file files

in dos:
copy /b files* file


much easier don't u think!!!!!!
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question