Path: utzoo!utgpu!water!watmath!clyde!bellcore!decvax!ucbvax!hplabs!pyramid!prls!mips!hitz From: hitz@mips.UUCP (David Hitz) Newsgroups: comp.unix.questions Subject: Re: Detecting pipe closure in shell script Summary: | (tee $TMP && mv $TMP $REAL || rm $TMP ) | more Message-ID: <1345@quacky.UUCP> Date: 16 Jan 88 10:40:02 GMT References: <380@dlhpedg.co.uk> Reply-To: hitz@quacky.UUCP (David Hitz) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 20 In article <380@dlhpedg.co.uk> cl@datlog.co.uk (Charles Lambert) writes: >I have a shell script with the following fragment in it: > > | tee $TFILE | more > >If I quit more(1) before output from tee(1) is complete, I want to >scrap $TFILE, else I want to move it to another name. I've tried ... >Charles Lambert Try | (tee "$TMP" && mv "$TMP" "$REAL" || rm "$TMP" ) | more If the more dies, then the tee fails because it cannot finish its writes. Note that the code above also has the effect of removing the $TMP file if the mv failes. -- Dave Hitz UUCP: {decvax,ucbvax,ihnp4}!decwrl!mips!hitz DDD: hitz@408-991-0345