truncate a 2gig file ?

Dale Shaw DShaw at
Wed Nov 27 15:54:13 EST 2002

Or just:

% cp /dev/null /path/to/file

Handy for clobbering logs without having to send a HUP to syslogd.


-----Original Message-----
From: Steven Farlie [mailto:steven.farlie at] 
Sent: Wednesday, 27 November 2002 3:49 PM
To: Simon Burton
Cc: linux at
Subject: Re: truncate a 2gig file ?

On Wed, 2002-11-27 at 15:37, Simon Burton wrote:
> Also i have wanted to zero length a file in the past,
> ie. just keeping the filename....

In a shell you can just redirect from nothing into the file using '>':

> filename

That should zero the file. If filename doesn't exist, then it will
create a new file of zero length.

More information about the linux mailing list