How to zero out a file in tcsh?

Jerry Feldman gaf at gaf.blu.org
Fri Feb 7 13:53:21 EST 2003


On Fri,  7 Feb 2003 08:58:23 -0800
dgavin at davegavin.com wrote:

> 
>  the "rm filename; touch filename" variation doesn't necessarily
>  preserve
> ownership or permissions depending on who does it and what their umask
> is. My personal favorite is "cat /dev/null > filename".
Yes, this will truncate the file, preserve permissions, and maintain the
filename as the same inode. However, there is a caveat. If the filename
is open and someone is reading or writing to the file, most likely that
read/write operation will fail. 
And yes, the rm command does not physically delete a file. If that file
has another link or if that file is open by another process, then the
rm/touch does not achieve the desired result. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.blu.org/pipermail/discuss/attachments/20030207/8429b56e/attachment.sig>


More information about the Discuss mailing list