Re: Bug#467378: coreutils: Please include a program to truncate files
From:
Russell Coker
Subject:
Re: Bug#467378: coreutils: Please include a program to truncate files
Date:
Tue, 26 Feb 2008 04:40:09 +1100
User-agent:
KMail/1.9.5
On Monday 25 February 2008 22:11, Jim Meyering <address@hidden> wrote:
> > One non-obvious feature request that I have is for a truncate on a
> > non-existant file to create it (similar to the way "touch" is commonly
> > used to create files).
>
> The obvious question is then "Why?"
One specific case is where I want a large sparse file to exist - which may
have been created previously. So "truncate 2g /var/spool/whatever/foo" would
make that file exist and be 2g in size regardless of whether it was there
before.
Of course writing shell code to check for the existence of a file is not
difficult, but the people who wrote touch(1) seemed to think this is a good
idea.