Re: to make file size o in a shell ?
From: Floyd L. Davidson (floyd_at_barrow.com)
Date: Mon, 29 Mar 2004 18:46:19 -0900
"David Schwartz" <email@example.com> wrote:
>"Floyd L. Davidson" <firstname.lastname@example.org> wrote:
>> "somez72" <email@example.com> wrote:
>>>I just want to truncate the file(tmp/mylog.dat) with size 0 , in a shell
> That won't work. His next write will restore the file to its original
That is precisely the way it is done (typically for syslog files
in /var/log, as an example), assuming the intention is to avoid
having to re-open the log file after it has been
> He has to open the file in append mode. Otherwise, he's going to have to
>code exactly what he wants because the system has no idea what it should do.
> For example, suppose the file is 1,024 bytes long. He seeks to byte 43
>and is about to write 10 bytes when the file is truncated to size zero.
>Where should the forthcoming 10 byte write go?
Yes, his C code has to comply. The point is, the file need not
be closed and reopened, which is exactly what must happen if it
-- Floyd L. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) firstname.lastname@example.org