Re: truncate file with shell

2003-06-24 Thread Peter Elliott
On Tue, 24 Jun 2003 21:40:24 +1200 Christopher Sawtell <[EMAIL PROTECTED]> wrote: > On Tue, 24 Jun 2003 20:52, you wrote: > > On Tue, Jun 24, 2003 at 08:22:13PM +1200, Christopher Sawtell wrote: > > > [EMAIL PROTECTED] chris $ ./truncate testfile 51 > > > [EMAIL PROTECTED] chris $ ls -l testfi

Re: truncate file with shell

2003-06-24 Thread Volker Kuhlmann
> It is...and I've just written a C program to call it. Yes, writing a short wrapper around the C lib function had occured to me, but I was wondering whether I was ignorant of some shell thing. Thanks much Tim for doing the work for me :)) Unfortunately, it doesn't work. off_t length;

Re: truncate file with shell

2003-06-24 Thread Christopher Sawtell
On Tue, 24 Jun 2003 20:52, you wrote: > On Tue, Jun 24, 2003 at 08:22:13PM +1200, Christopher Sawtell wrote: > > [EMAIL PROTECTED] chris $ ./truncate testfile 51 > > [EMAIL PROTECTED] chris $ ls -l testfile > > -rw-r--r--1 chrisusers 51 Jun 24 20:17 testfile > > [EMAIL PROTECTE

Re: truncate file with shell

2003-06-24 Thread Matthew Gregan
On Tue, Jun 24, 2003 at 08:22:13PM +1200, Christopher Sawtell wrote: > [EMAIL PROTECTED] chris $ ./truncate testfile 51 > [EMAIL PROTECTED] chris $ ls -l testfile > -rw-r--r--1 chrisusers 51 Jun 24 20:17 testfile > [EMAIL PROTECTED] chris $ echo $? > 0 This is the expected beh

Re: truncate file with shell

2003-06-24 Thread Matthew Gregan
On Tue, Jun 24, 2003 at 07:39:43PM +1200, Tim Wright wrote: > It is...and I've just written a C program to call it. Or you could skip mucking about with C and use something like Perl. This way, assuming your Perl supports it, you get largefile support for free. $ perl -e 'truncate "/path/to/file

Re: truncate file with shell

2003-06-24 Thread Rob Stockley
On Tue, 2003-06-24 at 20:22, Nick Rout wrote: > > > > cat your_file | tail --bytes=N > /tmp/tempfile ; mv /tmp/tempfile > > your_file > > > > Probably still not quite right. > > the man is talking +2G files. that method is likely to take a long time > and create a lot of time consuming disk acti

Re: truncate file with shell

2003-06-24 Thread Nick Rout
On Tue, 24 Jun 2003 20:16:15 +1200 Rob Stockley <[EMAIL PROTECTED]> wrote: > On Tue, 2003-06-24 at 20:06, Rob Stockley wrote: > > If it's a text file then how about, > > > > cat your_file | tail --bytes=N > your_file > > > > where N is the number of bytes to be kept. Can piping be made to > > op

Re: truncate file with shell

2003-06-24 Thread Christopher Sawtell
On Tue, 24 Jun 2003 20:16, you wrote: > On Tue, 2003-06-24 at 20:06, Rob Stockley wrote: > > If it's a text file then how about, > > > > cat your_file | tail --bytes=N > your_file > > > > where N is the number of bytes to be kept. Can piping be made to operate > > serially using a temporary file? P

Re: truncate file with shell

2003-06-24 Thread Rob Stockley
On Tue, 2003-06-24 at 20:06, Rob Stockley wrote: > If it's a text file then how about, > > cat your_file | tail --bytes=N > your_file > > where N is the number of bytes to be kept. Can piping be made to operate > serially using a temporary file? Perhaps this is a little dangerous to > be writing

Re: truncate file with shell

2003-06-24 Thread Rob Stockley
On Tue, 2003-06-24 at 15:54, Volker Kuhlmann wrote: > Is there a shell command which can truncate a file to the given number > of bytes? It would need to work with large files (i.e. >> 2GB). > > Thanks, > > Volker If it's a text file then how about, cat your_file | tail --bytes=N > your_file w

Re: truncate file with shell

2003-06-24 Thread Tim Wright
On Tue, 24 Jun 2003, Rex wrote: > Christopher Sawtell wrote: > > > > man 2 truncate > > > > System call, You'll have to write a trivial C program to call the kernel > > function. Surprisingly, nothing in man(1). > > Nope, `tis a function. man 2 truncate. It is...and I've just written a C program

Re: truncate file with shell

2003-06-23 Thread Rex
Christopher Sawtell wrote: man 2 truncate System call, You'll have to write a trivial C program to call the kernel function. Surprisingly, nothing in man(1). Nope, `tis a function. man 2 truncate. Rex

Re: truncate file with shell

2003-06-23 Thread Christopher Sawtell
On Tue, 24 Jun 2003 17:04, you wrote: > Thanks, but both split and dd can only copy the first (or more) part(s) of > a file to a new file. Copying the start of the file is trivial, but > requires disk space and a lot of time. Truncating it in place is what I'm > after. man 2 truncate System call,

Re: truncate file with shell

2003-06-23 Thread Volker Kuhlmann
Thanks, but both split and dd can only copy the first (or more) part(s) of a file to a new file. Copying the start of the file is trivial, but requires disk space and a lot of time. Truncating it in place is what I'm after. Thanks, Volker -- Volker Kuhlmann is possibly list0570

Re: truncate file with shell

2003-06-23 Thread Andre Renaud
> Is there a shell command which can truncate a file to the given number > of bytes? It would need to work with large files (i.e. >> 2GB). Have a look at "split". Andre

RE: truncate file with shell

2003-06-23 Thread Bjorn Nilsen
Check out "man dd", it may be able to do this. > -Original Message- > From: Volker Kuhlmann [mailto:[EMAIL PROTECTED] > Sent: Tuesday, 24 June 2003 3:54 p.m. > To: [EMAIL PROTECTED] > Subject: truncate file with shell > > > Is there a shell command which can truncate a file to the > gi