19

In the command-line, how can I create a zip file from a directory, whose name would be the current date?

I can use zip -r name dir, but how give it the date for a name?

1 Answer 1

40

By slipping the date command into the filename:

zip -r "archive-$(date +"%Y-%m-%d").zip" file1 file2 file3 file4

That just does year-month-day but you can use times, weeks, etc if that suits you more. You can read more about the substitution strings in man date.

1
  • 5
    for date with time: zip -r "archive-$(date +"%Y-%m-%d %H-%M-%S").zip" file1 file2 file3 file4
    – Samad
    Jul 20, 2016 at 10:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .