Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!oliveb!sun!gorodish!guy From: guy@gorodish.Sun.COM (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: make temp files? Message-ID: <69319@sun.uucp> Date: 21 Sep 88 08:04:49 GMT References: <48200010@hcx1> Sender: news@sun.uucp Lines: 14 > I was wondering if there is some "readymade" way that a shell can create a > unique temporary file, as in the C routine "mktemp(XXXXX)". Thanks! Not exactly like "mktemp", but both the Bourne (and Korn) and C shells have a variable "$$", which expands to the process ID of the shell. This is what most shell scripts use for temporary files, since the traditional UNIX trick for making unique file names is to stuff the process ID of the creating process into their names. "mktemp" does other things, of course, that the shell script would have to do itself. BTW, you probably want to use "trap" in the Bourne or Korn shell, and "onintr" in the C shell, to make sure the shell script cleans up its temporary files if interrupted. Not cleaning up your temporary files when interrupted is considered Very Rude, both for programs and shell scripts. (Yes, I know, SunView windows don't clean up; I consider them Very Rude....)