Welcome to WebmasterWorld Guest from 22.214.171.124 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
Bash command for last listing in directory Status_203 msg:4216269 3:34 pm on Oct 13, 2010 (gmt 0) How, in Bash, would you get the alphabetically last subdirectory in a directory. This is for an incremental rsync backup system. I want to name the directories by (ISO8601) date rather than using (fixed) numbered backups, but whether I use cp -al or use the --link-dest options, I need to know the directory of the last backup (I think).
graeme_p msg:4216424 8:10 pm on Oct 13, 2010 (gmt 0)
This seems to work for me on the command line: ls -1|grep pattern|tail -n 1 pattern should be something that matches the subdirectories you want given your naming scheme. I am a Bash newbie (I have used Linux for a long time, but GUI and other scripting languages) so please test or wait for more expert comments before using for anything as important as backups. Status_203 msg:4216602 9:14 am on Oct 14, 2010 (gmt 0)
Dagnammit, I know all those commands... I just keep forgetting about pipes! Seems a sensible suggestion to me. Thanks for the reminder.