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? Perhaps this is a little dangerous to > > be writing back to the same file. Maybe a short script? Rambling > > again.... :> > > Nope needed to be > > cat your_file | tail --bytes=N > /tmp/tempfile ; mv /tmp/tempfile > your_file > > Probably still not quite right. Tim's one is the closest
[EMAIL PROTECTED] chris $ gcc -o truncate truncate.c [EMAIL PROTECTED] chris $ dd if=/dev/zero of=testfile bs=1024 count=1024 1024+0 records in 1024+0 records out [EMAIL PROTECTED] chris $ ls -l testfile -rw-r--r-- 1 chris users 1048576 Jun 24 20:16 testfile [EMAIL PROTECTED] chris $ ./truncate testfile 500000 [EMAIL PROTECTED] chris $ ls -l testfile -rw-r--r-- 1 chris users 500000 Jun 24 20:17 testfile [EMAIL PROTECTED] chris $ ./truncate testfile 500001 [EMAIL PROTECTED] chris $ ls -l testfile -rw-r--r-- 1 chris users 500001 Jun 24 20:17 testfile [EMAIL PROTECTED] chris $ echo $? 0 True truncation? Shows the way to go though. Sorry to be a perfectionist. -- C. S.
