This came up when I was doing a lot of testing of some code that does printing; I wanted to print to PDF and then repeatedly view the output. But the CUPS PDF printer writes to /var/spool/cups-pdf/<username> by default, and I was naming the print jobs so they were different every time.
#!/bin/sh echo -n $1 ls -t $1 | head -1
xpdf `lsnewest /var/spool/cups-pdf/srutledge/`
The script should work whether you give it a directory as an argument, or if there is no argument, it will use the CWD.