kobontas bytes apo to telos enos binary arxeiou

I.Ioannou roryt at roryt.gr
Fri Feb 2 11:48:01 EET 2001


Fotos Georgiadis wrote:
> 
> Mporei na proteinei kanenas kapoio tropo gia na kopso x bytes ( < 60 bytes)
> apo to telos enos binary arxeiou. To arxeio einai megalo ( > 600 MB)
> opote sindiasmoi head -c kai tail einai axristoi. Kamia idea ?

Xmm, to megethos tou arxeiou mallon kanei apagoreytikes tis alles
lyseis.
Gia dokimase ayton to quick & dirty tropo :
swse se ena arxeio c.c, kane gcc -o c c.c, kai trekse
./c onoma teliko-megethos

--- cut here ---

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

int main(int argc, char ** argv)
{

  int res;
  off_t final_size;

  if (argc != 3)
  {
   printf("Usage: %s filename final-length\n", argv[0]);
   exit(1);
  }

  final_size=atol(argv[2]);

  res=truncate(argv[1], final_size);
  if (res == -1)
  {
    int er = errno;
    printf("Can't truncate %s, error %d, message : %s\n",
argv[1],er,strerror(er));
    exit(1);
  }

  return(0);

} 

--cut here--

I.Ioannou <roryt at roryt.gr>



More information about the Linux-greek-users mailing list