Article View: comp.unix.shell
Article #1106Re: How to do <cmd> file | hold file
From: Dan Bernstein
Date: Sun, 09 Sep 1990 03:04
Date: Sun, 09 Sep 1990 03:04
22 lines
1449 bytes
1449 bytes
In article <1215@tardis.Tymnet.COM> jms@tardis.Tymnet.COM (Joe Smith) writes:
> In article <2274@ns-mx.uiowa.edu> jlhaferman@l_cae07.icaen.uiowa.edu (Jeffrey Lawrence Haferman) writes:
[ how to sort a file and place output back into same file? ]
[ sort -o file file works ]
> In general, you have to find a suitable location to hold the file, then
> mv it to the destination.
No, you don't.
% ( rm file; foo > file ) < file
foo's input will point at the old file; its output will go into the new
file. If foo reads all its input early and close()s to indicate this,
the disk space for the original will immediately disappear, provided
that it had only one link. If it had several links then the others will
stay around, entirely unaffected.
(I think cp foo bar should work like ( rm -f bar; cat > bar ) < foo, so
that other links to bar won't be affected; but POSIX 1003.2 apparently
disagrees and has cp foo bar work like cat < foo > bar. Oh, well.)
---Dan
Technical Details
Message-ID:
<8029:Sep903:04:5390@kramden.acf.nyu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!rpi!sci.ccny.cuny.edu!phri!cmcl2!kramden.acf.nyu.edu!brnstndReferences:
<2274@ns-mx.uiowa.edu> <1215@tardis.Tymnet.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!rpi!sci.ccny.cuny.edu!phri!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.unix.shell Subject: Re: How to do <cmd> file | hold file Message-ID: <8029:Sep903:04:5390@kramden.acf.nyu.edu> Date: 9 Sep 90 03:04:53 GMT References: <2274@ns-mx.uiowa.edu> <1215@tardis.Tymnet.COM> Organization: IR Lines: 22