[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

tarring into multiple files

Posted on 1998-12-24
3
Medium Priority
?
263 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 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.:
Suggested Courses

649 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