From Electron Cloud
This came up when I was doing a lot of testing of some code that does printing; I wanted to repeatedly print to PDF and 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
Usage:
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.
An improvement would be a FUSE filesystem that "mounts" the output of any script like this onto a directory, e.g. /var/spool/cups-pdf/last. It would be useful in other ways too (a kind of "smart folders").