• bash,  Uncategorized

    Scripting the Temp and Cache Directories on a Mac

    Ever see a weird folder like /var/folders/g0/lr10g_wx4t75s2hd5129qhkc0000gn/T/ and wonder why it’s there? Those are usually Darwin or shell temporary or cache directories. They are where those weird temp directories you need to access are written to and read from. Apple uses these to host volatile sql databases and a number of scripts use them to house a file and protobuffs prior to processing. You too can access them in your scripts when needed. The most common is a built-in shell temp that you can easily access just by echoing out the contents of $TMPDIR: echo $TMPDIR Darwin has some as well; most notably in DARWIN_USER_CACHE_DIR and DARWIN_USER_TEMP_DIR where each can…