Tuesday, 1 October 2013

Copy latest created directory

Copy latest created directory

I would like to make a second backup from the latest created backup. So I
tried the shell command:
last='ls -tr | tail -1'
cp -r /path/.../"$last" /path/.../backup/
but it copies a randome backup.
It is working perfect with .zip and .tar files but not with folders as I
need it here.
I googled for a solution but couldn´t find anything related to this, I
hope you can help me.
It would also be possible to use the name of directory which is for example:
2013-09-27-05-22-45

No comments:

Post a Comment