Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
There's also no guarantee you'd just need another 20gb of space, it really depends on compression ratios. –  Rich Homolka Feb 26 '13 at 18:27
    
Of course. I understand it. –  Igor Konoplyanko Feb 26 '13 at 18:33

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
    
+1 for a useful answer, a good explanation and the use of && in combination with the delete command. –  Hennes Feb 26 '13 at 19:57
    
I knew it. Solution exists! :) –  Igor Konoplyanko Feb 26 '13 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 –  saber tabatabaee yazdi Mar 2 '13 at 4:51
    
+1 for smart solution, as well as well explained and detailed. –  Lorenzo Von Matterhorn Mar 6 '13 at 15:06

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.