Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Mar 1999 08:33:56 +1000
From:      Greg Black <gjb@comkey.com.au>
To:        dissonant <disowned@linda.pomona.edu>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: empty a file? 
Message-ID:  <19990327223356.13535.qmail@alpha.comkey.com.au>
In-Reply-To: <Pine.BSF.4.05.9903270446260.52265-100000@linda.pomona.edu>  of Sat, 27 Mar 1999 04:48:11 PST
References:  <Pine.BSF.4.05.9903270446260.52265-100000@linda.pomona.edu> 

next in thread | previous in thread | raw e-mail | index | archive | help
> Sorry to ask a dumb unix question....but, is there any easy way, in the
> shell or in a script of some sort, to empty a file, leaving its
> permissions, uid/gid, etc, untouched?

The two traditional idioms (for scripts and interactive use)
are:
	cp /dev/null your.file
	: >your.file

Being a minimalist, I prefer the second one :-)

It's possible to save a couple of characters in the minimalist
version, but that tends to lead to obscurity for no real gain.

-- 
Greg Black <gjb@acm.org>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990327223356.13535.qmail>