Xref: utzoo comp.unix.xenix.sco:1203 comp.unix.shell:1154 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!tut.cis.ohio-state.edu!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.xenix.sco,comp.unix.shell Subject: Re: emptying a file and keeping its ownership Message-ID: <1990Dec31.214030.7816@athena.mit.edu> Date: 31 Dec 90 21:40:30 GMT References: <1990Dec30.220722.29050@jarvis.csri.toronto.edu> Sender: news@athena.mit.edu (News system) Reply-To: jik@athena.mit.edu (Jonathan I. Kamens) Distribution: na Organization: Massachusetts Institute of Technology Lines: 32 Several people have suggested using > $FILE to truncate a file while retaining its old permissions. This will work under sh or ksh or bash or other shells that allow null commands for redirection. Unfortunately, csh and tcsh do not allow such null commands :-(. Therefore, I'd like to point out another way to do this that works on most platforms I've seen. From the man page for cp(1): DESCRIPTION File1 is copied onto file2. By default, the mode and owner of file2 are preserved if it already existed; otherwise the mode of the source file modified by the current umask(2) is used. Therefore, you can use cp /dev/null $FILE to truncate a file and save its current permissions. I hope this helps. -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710