1
alias backupfolder='tar -zcvf $1_$(date '+%Y-%m-%d').tar.gz $1'

This alias creates the tar archive, but the naming is just __YYYY-MM-DD.tar.gz. I'm trying to get folder__YYYY-MM-DD.tar.gz.

Do i need some special symbols in the $1 before _?

Daniel F
  • 13,684
  • 11
  • 87
  • 116
oppsig
  • 181
  • 1
  • 8

1 Answers1

3

Use a function.

backupfolder() { tar -zcvf "${1}_$(date '+%Y-%m-%d').tar.gz" "$1"; }

or a script in your path.

chepner
  • 497,756
  • 71
  • 530
  • 681
Paul Hodges
  • 13,382
  • 1
  • 17
  • 36