I'm writing a script that unzips an archive, edits it, and zips it back up.
That being said, I've got it all figured out except for the zipping it back up.
Code:
unzip file.zip -d /tmp/foobar
##regexes###
Now when i get to zipping the files back up, I don't want to include the /tmp/foobar directory I created. I want it to have the same tree as before.
I've gotten two commands to come close, but not what I want.
Code:
zip -r /tmp/file.zip /tmp/foobar/*
- this zips up the folders and files within /tmp/foobar/ however, it includes the /tmp/foobar tree.
Code:
zip -rj /tmp/file/zip /tmp/foobar/*
- this gets rid of the directories, however, it gets rid of ALL the directories, and doesn't preserve any within /tmp/foobar.
Now, by default zip will ignore /tmp/foobar if you're in that directory and running zip from there. But since this is a script I don't want to be limited to where I can run the script, or lower my standards to including changedirectory lines in my script. It seems to me like I should be able to 1-liner it, and it's frustrating me.
Anyone use zip enough to be able to help me?