Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
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". Dave Gavin Quoting John Jannotti <jj at lcs.mit.edu>: > > > > Jerry Feldman <gaf at h0020780e341c.ne.client2.attbi.com> writes: > > On Thu, 6 Feb 2003 22:29:15 -0500 > > Derek Martin <blu at sophic.org> wrote: > > > > > One method to do this regardless of how your shell handles redirection > > > and what flavor of echo you have is this: > > > > > > rm filename; touch filename > > I fully concur with Derek. This is full portable accross all versions of > > Unix and Linux. As mentioned in the other posts, echo, while a shell > > builtin may have different behavior depending on the shell. > > But it doesn't do the same thing. The other examples truncate the existing > file, this doesn't. It's possible this makes a difference. One of the > reasons you might be doing this is to reclaim disk space. If a process has > the file open, truncating it still reclaims the space, deleting it doesn't. > > Or, perhaps you know that something is doing the equivalent of "tail -f" on > the file, and another process is appending to it. If you delete and > recreate, those processes are not talking to each other any more. > > I think "cat > filename", then ^d is probably the shortest portable > way. (or echo -n > filename is you're not interactive). > > jj > > _______________________________________________ > Discuss mailing list > Discuss at blu.org > http://www.blu.org/mailman/listinfo/discuss >
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |