Marco
Marco

Reputation: 4395

Linux: Create Tar file with MD5 hashsum of Current Date

How can I accomplish the following?

date '+%d' | md5sum | tar -czf $_.tar.gz file

I would like the filename.tar.gz to be that of the md5sum output.

Upvotes: 0

Views: 3144

Answers (3)

unbeknown
unbeknown

Reputation:

This is not an answer to your question.

Why do you need to MD5 hash the date? Why not use the date itself? Usually you hash something, when you don't want the reverse operation to happen. In your case: you want to prevent that someone can find the date from the hash. But there aren't to many possible dates and it can easily be found by brute force. Even the creation timestamp of the file can give you hints in what range to look for the date. All in all I can't see a reason to use a cryptographic hash instead of the original date.

Upvotes: 0

Marco
Marco

Reputation: 2336

You can do that like this

tar -czf `date '+%d' | md5sum`_.tar.gz file

Upvotes: 0

Steve-o
Steve-o

Reputation: 12866

tar -czf `date '+%d' | md5sum | sed -e 's/  -//'`.tar.gz file

Better suited to serverfault.com.

Upvotes: 2

Related Questions