18 ms·
I frequently need to create datestamped archives. Here is a one-line example, given two parameters. $1 is the archive name prefix and $2 is the directory to ar
by blogimus 17y ago
I frequently need to create datestamped archives.
Here is a one-line example, given two parameters. $1 is the archive name prefix and $2 is the directory to archive.
tar -cvzf ${1}-$(date +%Y%m%d-%H%M).tar.gz $2
Note, if $2 contains path information (such as absolute path), that path will be stored in the tar. So it is usually used with the working dir as the parent of $2.