homepage Welcome to WebmasterWorld Guest from 23.20.220.79
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved