VMS-to-Unix Phrase Book
<=  Return           

2.1  Scratch Directories

Problem

You want to create temporary files for intermediate steps in a process, or you want to discard unwanted output.

Solution

Use /tmp which is analogous to VMS's SYS$SCRATCH:, and /dev/null which is analogous to VMS's NL:

Discussion

In VMS the SYS$SCRATCH: logical points to your own scratch directory on the scratch disk, or if there is no scratch area, your own home directory. In contrast the /tmp is shared directory by all users. To avoid name collisions, you may want to create your own subdirectory within that area whenever it is needed:

    if [ ! -e /tmp/$USER ]
    then mkdir /tmp/$USER;
    fi;
    cp big-file /tmp/$USER;
You can also create unique temporary filenames by using the special shell variable $$ which returns the process ID of your current process:
unix> sort big.1 big.2 big.3 >/tmp/$USER/really-big.$$
unix> ls /tmp/$USER/really-big.$$
/tmp/wfc/really-big.1853768
unix>

The special file /dev/null can be used for discarding output, or if used as an input source, it will immediately return end-of-file.

unix> some-noisy-program >/dev/null

unix> mailx -s "job XYZ aborted" $USER </dev/null

See Also

1.4 - Symbols and Logicals;
Chapter 2 of Unix for OpenVMS Users ;
Chapter 22 of Unix Power Tools .


<=  Return           

Colophon:
Best Viewed With Any Browser
This page maintained by:
    Bill.Costa@unh.edu
    of the Enterprise Computing Group
    in the dept of Computing & Information Sevices
    at the University of New Hampshire

Typographical
Conventions

Created:  31-Jan-2001 BC
Revised:  27-Mar-2001 BC