Hey Thanks all! I got it ;)
open (FH, "+< $fname")|| die "\nFailed to open file $fname\n"; my $tmp=$fsize-$trunccount; seek(FH,$tmp,0); $addr = tell(FH) ; truncate(FH, $addr)|| die "\nFailed to truncate $file: $!"; close(fd); print "\nTruncate successful\n"; On Fri, May 20, 2011 at 6:07 PM, Paul Johnson <p...@pjcj.net> wrote: > On Fri, May 20, 2011 at 03:40:35PM +0530, a b wrote: > > > Hi All, > > > > I need to truncate last few bytes of file. these files are big in size. > > > > One idea is to write needed bytes to another file and delete the original > > file, but i am dealing with big files :( > > > > dont want to use truncate, it just truncating the size, all data is gone > > > > any pointers > > truncate()'s second parameter is the length to which you want to > truncate. Did that not work for you? If not, I would suggest posting > some example code that fails, because calling truncate() seems to be the > correct approach here. > > -- > Paul Johnson - p...@pjcj.net > http://www.pjcj.net >