find directories in the current directory, older than 5 days and archive them

Posted by user197284 on Server Fault See other posts from Server Fault or by user197284
Published on 2013-11-06T19:36:27Z Indexed on 2013/11/06 21:56 UTC
Read the original article Hit count: 173

Filed under:
|
|
|
|

This is basic questions. I need to find folders in the current working directory(not recursively) and if they are older than 5 days archive them. zip or tar.gz is fine.

I can find the folders with following commands

find ./ -maxdepth 1 -type d -mtime +5

And i know i can pass this output of the find using xargs. But i do not know how to archive with folder name intact.

That is the directory test1 should be archived to test1.zip and directory "test2" should be archived to "test2.zip".

Any inputs are welcome.

Regards

© Server Fault or respective owner

Related posts about shell-scripting

Related posts about directory