Are there other options to unzip a file in Ubuntu besides "unzip"? [closed]
I haven't tried this, but, there's a zipfile
module in Python's standard library since version 1.6, and since version 2.6 has had an extractall
method
You should be able to do something like:
- Create a file with the following contents (editing it to fit your use case).
- Save the file as "unzipfile.py"
- Run with python unzipfile.py
And it'll extract test.zip
to /home/user/directory
.
import zipfile
with zipfile.ZipFile('test.zip', "r") as z:
z.extractall("/home/user/directory")
Source: https://stackoverflow.com/a/9432315/167299
Alternatively, BusyBox contains an unzip "module", and if you could download and run the statically-linked BusyBox, then you could use that to unzip things.
If you have java
installed, the jar
command can unzip a zipped file:
jar xvf file.zip
Note that you can install java without root access: http://docs.oracle.com/javase/7/docs/webnotes/install/linux/linux-jdk.html
Update: OpenJDK is downloadable for Linux as a tar.gz
archive installable without root access here: http://jdk.java.net/17/
The Windows version is however a zip
file so that wouldn't help on that OS...
I don't believe there are other ways of unzipping the file on a system without unzip
, but you could send the file to another linux system (with unzip installed or root access available), unzip the file there and - if necessary - send the unzipped file back to the original server.
The command to send a file from one server to another is scp
. The syntax to send the file is:
scp <filename> <username>@<otherhostname>:<portnumber><fullpathtolocation>
e.g.: scp file.zip [email protected]:2222/home/user/
Hope this helps!
BSD / Mac OSX
The tar utility that ships with Mac and BSD derivatives, support extracting zip archives from the tar command
tar -xvf foo.zip
tar --version
bsdtar 2.8.3 - libarchive 2.8.3
Debian / RHEL
The tar archive that ships with Ubuntu and others does not support extracting zip files. The best option will be to scp the file to a machine with zip installed.
tar -xvf foo.zip
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
Smoke Test
echo "the quick brown fox jumped over the lazy dog" > bar.txt
zip -r bar.zip bar.txt
rm bar.txt
tar -xvf bar.txt
cat bar.txt
the quick brown fox jumped over the lazy dog
Update
Rewrote answer to clarify that tar -xvf only works on bsd OS's. While it is good information, It will not work in this scenario after all.