I've got two directories.
/application/inbox
/application/unresponsive
The application looks for *.txt files in the inbox and works with them. Periodically the application will save entries from these files into date-named (2009-07-31) files in the unresponsive folder.
I'd like to setup a cron job which works once a day to move the oldest file from the unresponsive box into the inbox, adding a *.txt extension so it's picked up by the application.
Untested, likely buggy:
If you want it to work with files with spaces (more robust). You should loop over them and use the -nt (newest based on modified time) or -ot (oldest) comparison operator with a basic min/max algorithm. Here is an example from this excellent BashFAQ:
So your example would be (untested):
Learning how not to use the output of ls is better I think. Here is link to the argument why. But I leave it up to you to decide if that is true or just pseudo-unix-guru nonsense :-)