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
  • 12,968
  • 10
  • 84
  • 107
oppsig
  • 181
  • 1
  • 7

1 Answers1

3

Use a function.

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

or a script in your path.

chepner
  • 446,329
  • 63
  • 468
  • 610
Paul Hodges
  • 10,927
  • 1
  • 16
  • 30