#include <stdio.h>
char buf[4096];
main(int argc, char **argv)
{
long skip=0;
unsigned long total=0;
unsigned long outp=0;
FILE *of,*nf;
int x;
size_t count=1;
if (argc < 4 || argc > 5)
help_exit(1);
skip=atol(argv[3]);
if (argc == 5)
total=atol(argv[3]);
if ((of=fopen(argv[1],"rb"))==NULL)
{
printf("No %s file??\n",argv[0]);
help_exit(1);
}
if ((nf=fopen(argv[2],"w"))==NULL)
{
printf("No %s file??\n",argv[0]);
help_exit(1);
}
if(skip)
fseek(of,skip,SEEK_SET);
if (!total)
{
while (1)
{
long bread;
bread=fread(buf,4096,1,of);
printf(" %d ",bread);
if( !bread) break;
fwrite(buf,bread,1,nf);
printf(".");
}
}
else
{
while (outp < total)
{
long bsize;
long bread;
bsize=4096;
if (total - outp < 4096)
bsize=total-outp;
bread=fread(buf,bsize,1,of);
printf(" %d ",bread);
if( !bread) break;
fwrite(buf,bsize,1,nf);
printf(".");
outp += bread;
}
}
fclose(of);
fclose(nf);
printf("\n");
exit(0);
}
help_exit(int arg)
{
printf("\n\nSKIPBYTE oldfile newfile skip-bytes [total-bytes]\n");
printf("Reads 'oldfile' skipping 'skip-bytes' bytes and stopping\n");
printf("after 'total-bytes' are copied (copied to newfile, not read\n");
printf("from oldfile\n");
printf("'total-bytes' is optional\n");
printf("\n\n(C)1993 Lawrence & Clark, Inc (781) 784-5537 (206) 323-2864\n\n\n");
exit(arg);
}
Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)
| Views for this page | ||||
|---|---|---|---|---|
| Today | This Week | This Month | This Year | Overall |
| 2 | 7 | 9 | 9 | 894 |
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Click here to add your comments