0

I want to be able to exclude some subfolders when compressing a folder during a rutine backup, and I did manage to do it, with something like this.

file=whatever
time='+%y-%m-%d'
folder=whatevertoo
zip -r ${file}$(date ${time}).zip ${folder} -x '*/ignoredir/*'

This works wonders, but I need the ignoredir to be passed as an argument or defined by a variable, and then is when I can't find a solution.

This does not work. The " ' " destroys the purpose of the " $ " to invoke a variable.

exclude=ignoredir
zip -r ${file}$(date ${time}).zip ${folder} -x '*/${exclude}/*'

Tried diferent combinations but nothing worked so far as for now.

p4x
  • 384
  • 1
  • 5
  • 16
  • [this?](http://stackoverflow.com/questions/25263199/linux-zip-and-exclude-dir-via-bash-shell-script) – Eugeniu Rosca Jul 01 '15 at 01:42
  • @EugeniuRosca Nah, this is a much simpler problem, and a massive FAQ at that. – tripleee Jul 01 '15 at 06:42
  • @tripleee: you are damn right (the problem is much simpler)! However, at first sight, there is no connection between the two topics (the original and the duplicate). Anyways, the OP has probably understood the root-cause. – Eugeniu Rosca Jul 01 '15 at 07:09
  • I'm thinking that *"The " ' " destroys the purpose of the " $ " to invoke a variable."* sounds like the OP was on to the root cause, but unable to figure it out. – tripleee Jul 01 '15 at 07:33

0 Answers0