Is it possible to run shell commands inside zip files

zip

Is it possible to run a shell script inside a zip folder in Linux? I have a shell script that is saved inside a zip folder, and I'd like to run the shell script inside the zip file (as if the zip file were a directory).

All that I'm trying to do now is run the command ls inside a zip file (so that the command will run inside the zip folder, and run just as if the zip folder were an unzipped folder.)

Best Answer

You asked if it's possible: yes, this is possible if you mount the zip as a filesystem (or, of course, if you unzip the archive, which I'm assuming you're explicitly not willing to do from Some Good Reason).

See Fuse-Zip for a tool that will do this. You could then do something like:

$ mkdir foo ; fuse-zip foo.zip foo
$ foo/running-my-script-in-foozip.sh
...
$ fusermount -u foo ; rmdir foo

Note that this is going to requires fuse, which in-turn requires a kernel module that you may or may not have. But you asked if it was possible, not if it was convenient.

Related Question