Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!boulder!stan!dce From: dce@Solbourne.COM (David Elliott) Newsgroups: comp.unix.wizards Subject: Unlinked temp files in sh scripts Message-ID: <871@marvin.Solbourne.COM> Date: 25 Apr 89 14:26:33 GMT Reply-To: dce@Solbourne.com (David Elliott) Organization: Solbourne Computer Inc., Longmont, Colorado Lines: 27 This is a trick that Dave Hitz (hitz@auspex.com) and I worked out last year: exec 3>temp.$$ 4&3 After this has been done, fd 4 is still a read descriptor pointing at the beginning of the temp file, so you can read the data in the file by redirecting from fd 4, or, if you need to read it multiple time, by dup'ing fd 4 ("exec 5<&4", for example, to copy it to fd 5). When you're finished, there's no need to clean up, since the file was removed before it was even used. Of course, it is possible to kill the program between the time the temp file is created and the time when it is removed, but at worst you'll end up with an empty file. -- David Elliott dce@Solbourne.COM ...!{boulder,nbires,sun}!stan!dce