Reputation: 285
I have a zipped file containing 10,000 compressed files. Is there a Linux command/bash script to unzip only 1,000 files ? Note that all compressed files have same extension.
Upvotes: 6
Views: 4115
Reputation: 815
unzip -Z1 test.zip | head -1000 | sed 's| |\\ |g' | xargs unzip test.zip
Upvotes: 5
Reputation: 285
I did this:
unzip -l zipped_files.zip |head -1000 |cut -b 29-100 >list_of_1000_files_to_unzip.txt
I used cut to get only the filenames, first 3 columns are size etc.
Now loop over the filenames :
for files in `cat list_of_1000_files_to_unzip.txt `; do unzip zipped_files.zip $files;done
Upvotes: 1
Reputation: 1700
You can use wildcards to select a subset of files. E.g.
Extract all contained files beginning with b:
unzip some.zip b*
Extract all contained files whose name ends with y:
unzip some.zip *y.extension
You can either select a wildcard pattern that is close enough, or examine the output of unzip -l some.zip
closely to determine a pattern or set of patterns that will get you exactly the right number.
Upvotes: 1
Reputation: 247
Some advices:
Upvotes: 0