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?
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
.