Unlinked temp files in sh scripts

David Elliott dce at Solbourne.COM
Wed Apr 26 08:43:18 AEST 1989


In article <871 at marvin.Solbourne.COM> dce at Solbourne.com (David Elliott) writes:
>
>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).

Oops.  Looks like I screwed up here.  You can't do an "exec 5<&4"
because 5 and 4 will still point to the same place.  Instead, you have
to do multiple redirections before the temp file is removed.

This is kind of sad, but I don't think you generally need to make more
than a couple of passes on the temp file.

-- 
David Elliott		dce at Solbourne.COM
			...!{boulder,nbires,sun}!stan!dce



More information about the Comp.unix.wizards mailing list