2

I want to unpack 20Gb archive, but I don't have another 20-30Gb of HDD free space. Is it possible to unpack this file over itself ?

So that zip file will be deleted after unpacking and I will have unpacked content.

2
  • There's also no guarantee you'd just need another 20gb of space, it really depends on compression ratios. Feb 26, 2013 at 18:27
  • Of course. I understand it. Feb 26, 2013 at 18:33

2 Answers 2

4

There's no -m (move) switch for unzip as there is for zip, but you can extract the files from the archive one by one and delete them immediately after extracting them.

I don't know much about OS X, but this works with Bash on Ubuntu:

IFS=$'\n'

for file in `zipinfo -Z1 ZIPFILE`; do
    unzip ZIPFILE $file && zip -d ZIPFILE $file
done

rm ZIPFILE

unset IFS
  • IFS=$'\n' sets the internal field separator to newline, so filenames that contain spaces will get handled properly.

  • zipinfo -Z1 ZIPFILE lists the contents of ZIPFILE, one by line.

  • for file in `...`; do ??? done loops through the output of ..., sets the variable file to one line the output of the command and executes ???.

  • unzip ZIPFILE $file && zip -d ZIPFILE $file extracts the file specified in file from the zipfile and deletes it from the archive (zip -d).

    Here, && makes sure the second command gets executed only if the first terminated successfully.

  • rm ZIPFILE removes the (empty) archive.

  • unset IFS restores the default value of the internal file separator.

4
  • +1 for a useful answer, a good explanation and the use of && in combination with the delete command.
    – Hennes
    Feb 26, 2013 at 19:57
  • I knew it. Solution exists! :) Feb 26, 2013 at 20:17
  • if you have a good internet connection you can upload them or if you have DVD writer you can burned them to 3 DVDs Mar 2, 2013 at 4:51
  • +1 for smart solution, as well as well explained and detailed. Mar 6, 2013 at 15:06
0

I believe it is not possible. In your case you will need an extra storage media to send the extracted content; or move the zip to it and extract it to your hard drive.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .