I have problem when zipping a folder, lets say I have folder Project with node_modules to be excluded, but I want to include only node_modules/mydir in my zip.
I tried with zip -r project.zip Project/ -x Project/node_modules/\* surely it removes mydir and also not zipping node_modules folder.
for now I just do a double zip, not that efficient, but do the job. currently looking for more efficient ways.
Anyone has any clue to achieve that?
Or I have to do loop on -x "node_modules/<otherfolder>" leaving node_modules/mydir included?
Here is one way to do it:
shopt -s dotglob extglob nullglob
zip -r project.zip Project/!(node_modules) Project/node_modules/mydir
Try this:
shopt -s extglob
zip -r project.zip Project/ -x@<(printf "%s/*\n" Project/node_modules/!(mydir))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With