bug-ed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-ed] editing a large file with ed


From: Bob Proulx
Subject: Re: [Bug-ed] editing a large file with ed
Date: Wed, 1 Aug 2012 22:58:21 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

Antonio Diaz Diaz wrote:
> Enda wrote:
> > I am trying to empty the contents of a file. The above works, but
> 
> Is there any reason to read the whole "largefile" in /tmp just to
> truncate it, instead of, say, doing a "rm" followed by a "touch"?

If it is a big file such as a logfile and a process might still be
writing to it then removing the file won't free up the disk space
until the last file handle to it has been closed.  This is an often
occurring question which is why I mention this.

Therefore to truncate a file and to ensure that the disk space is
freed immediately regardless of a process still possibly writing to it
I recommend simply truncating the file using the shell.  Then there is
no need to create it again with touch or to need to adjust permissions
afterward or anything like that.

  $ > largefile

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]