I'm writing a backup script of sorts.  My backup server contains 3 directories (named by date in the MM-DD-YYYY format)For example:12-22-2015 12-28-2015 12-29-2015Im writing my backup script now to find the oldest directory (12-22-2015) and will name it to todays date (in preparation for an rsync).My question is, is it possible to find the oldest directory (can be done by either the oldest directory name which is MM-DD-YYYY -OR- by the unix timestamp for that directory --  would prefer unix timestamp as this should be more accurate?)The catch is I need to store the directory name of the oldest directory as a variable in my local scriptIm performing all calls to my remote server via ssh command type callsThank you!
Find oldest directory name on a remote server?
bash;shell script;files;sort;timestamps
ls -t sorts files by mtime (youngest first), and ls -r reverses the sort order, so both var=$(ssh $remote ls -t | tail -n 1) or var=$(ssh $remote ls -tr | head -n 1) should work.