The below bash code snippet explains my problem. I want to generate the arguments after the -i, at the time of calling the zip command.
#!/bin/bash
from_date=2020-05-17
to_date=2020-06-17 #tomorrow's date
w='"*a*" "*b*"'
# doesn't work
find . -newermt "$from_date" ! -newermt "$to_date" | zip zipf.zip -@ -i $w
#works
find . -newermt "$from_date" ! -newermt "$to_date" | zip zipf.zip -@ -i "*a*" "*b*"
The last line works because I hardcoded the parameters. However, if I use the w
variable, and I have tried many ways of writing it but without success, it comes up with an error like:
zip error: Nothing to do! (zipf.zip)
What value of the w
variable will work in this case?