I'm testing an app that uses the System temp Directory. Inside of the app, there is some call to a Cocoa function to query this. Is there a way for me to query for this directory name outside of having to write a Cocoa app of my own? Possibly a command that I can issue in Terminal?


2 Answers 2


Just type this command into Terminal. With zero arguments it'll print the names and values of variables in the environment.

Alternative with a bit more typing:

echo $TMPDIR
  • 2
    Thanks. What a weird path - /var/folders/iz/izqn2b5MF-iz9oL0CURH1U+++TI/-Tmp-/
    – bpapa
    Commented Nov 13, 2010 at 20:32
  • 3
    This is not a good answer, since this env variable points to different directory every time a different process is invoked. It is made to let each process freely write into a "temp" directory, without worrying that it might overwrite (or read by mistake) something another application wrote. Commented Apr 4, 2016 at 10:08

OS X has Python pre-installed, though not necessarily a fresh Python; but this is not cutting-edge stuff.


Open a terminal

cat > hack.py
import tempfile
print tempfile.gettempdir()
python hack.py

Credit to nosklo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .