Make tar of most recent directories
I have a tree of directories, and I would like to archive the most recent directory at the last level (i.e, of the directories that don't contain subdirectories). Alternatively, I can rm the older directories and tar what's left. Maybe a picture would help:
Code:
I assumed some brilliant pattern to find would do this, but if so it is far beyond my newbie skills. |
Code:
tar cvzf new_dir.tar.gz `find -type d -mindepth 3 -maxdepth 3 -exec ls -ld --time-style=long-iso {} \; | sort -g -k 6,7 | tail -n 1 | awk '{print $8}'` It's a bit of a mouthfull but should work ;) Cheers, Tink |
All times are GMT -5. The time now is 08:06 PM. |