Linux unzip multipart files

Как разархивировать многочастный (составной) ZIP на Linux?

Мне нужно загрузить файл 400 МБ на мой веб-сервер, но я ограничен загрузкой 200 МБ. Мой хост предложил мне использовать составной архив, чего я никогда не делал в Linux.

Я создал тест в своей папке, сжать вверх PDF в test.zip.001 , .002 и .003 . Как мне разархивировать его? Нужно ли сначала присоединиться к ним?

Обратите внимание, что я буду так же рад использовать 7z, как и форматы ZIP. Если это имеет какое-либо значение для результата.

Сначала вам нужно присоединиться к ним. Вы можете использовать обычное приложение linux, cat как в примере ниже:

Это сцепить все ваши test.zip.001 , test.zip.002 и т.д файлов в один большой, test.zip файл. Если у вас есть этот единственный файл, вы можете запустить unzip test.zip

/hugefile это каталог? Какова цель символа тильды? Извините, что спрашиваю, что я подозреваю, это очень простые вопросы.

/ огромный файл — это то же самое, что и / дом / Тим / огромный файл. ты разделил свои файлы? что такое имена разделенных файлов?

unzip Утилита Linux на самом деле не поддерживает составные почтовые индексы. Из руководства :

Многокомпонентные архивы пока не поддерживаются, кроме как в сочетании с zip. (Все части должны быть соединены вместе по порядку, а затем zip -F (для zip 2.x) или zip -FF (для zip 3.x) должны быть выполнены для объединенного архива, чтобы «исправить» его. Кроме того, zip 3.0 и более поздние версии могут объединяться многочастные (разделенные) архивы в объединенный однофайловый архив с использованием zip -s- inarchive -O outarchive . Для получения дополнительной информации см. справочную страницу zip 3. )

Таким образом, вам нужно сначала соединить части, а затем восстановить результат. cat test.zip.* объединяет все файлы, вызываемые test.zip.* там, где подстановочный знак * обозначает любую последовательность символов; файлы нумеруются в лексикографическом порядке, который совпадает с числовым порядком благодаря нулям в начале. >test.zip направляет вывод в файл test.zip .

Если вы создали фрагменты, непосредственно разбив zip-файл, в отличие от создания zip-файла из нескольких частей с помощью официальной утилиты Pkzip, все, что вам нужно сделать, это соединить части.

Источник

How do I unzip multiple / many files under Linux?

The problem with multiple zip files on Linux

Assuming that you have four file in a /disk2/images/ directory as follows:

Let us verify it with the ls command:
$ ls
Sample outputs:

To unzip all files, enter:
$ unzip *.zip
Sample outputs:

Above error indicate that you used the unzip command wrongly. It means extract invoices.zip, pictures.zip, and visit.zip files from inside the data.zip archive. Your shell expands the command ‘unzip *.zip’ it as follows:
unzip data.zip invoices.zip pictures.zip visit.zip
The solution is pretty simple when you want to unzip the file using the wild card; you have two options as follows.

#1: Unzip Multiple Files Using Single Quote (short version)

The syntax is as follows to unzip multiple files from Linux command line:

Type the following command as follows:
$ cd /disk2/images/
$ unzip ‘*.zip’
$ ls -l

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard
Читайте также:  Windows people who do

Join Patreon

Note: *.zip is put in between two single quotes so that shell will not recognize it as a wild card character.

#2: Unzip Multiple Files from Linux Command Line Using Shell For Loop (Long Version)

See also

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

# If files are password protected, and we are not sure which password

for Z_FILE in *.zip; do
for PASSWD in [ pass123, PASS123, abc123, ABC123 ]; do
unzip -P $PASSWD $Z_FILE;
if [ $? = 0 ]; then # successful unzip
break
fi
done
done

This is an excellent hack.

Appreciate your post.

> Appreciate your post.

No probs, copyleft (c) 🙂

Actually I’ve seen yours:

$ for z in *.zip; do unzip $z; done

But, it was not enough for me, ’cause we have password protected ones… So, can say that idea comes from you 🙂 I just added a new feature (validation)…

I think it should/can be improved further to check for other exit status codes…

Maybe later some day…

I used to use for i in *.zip ; do unzip $i ; done as well but then I found out about the following command and use it all the time now.

escape the asterik and you are good to go. 🙂

I tried unzip -P $PASSWD $Z_FILE; command but it is not working and for same zip file it is working in US with same password. I read in one of the web sites that, non USA system needs to install a patch for running above command. If yes Please let me know where can I get this patch else please let me know how to run this command.

Thanks, just what I needed! Very straitghtforward. +1 virtual cookie for you.

If you have spaces in your filenames, you can also use the following:

for z in *.zip; do unzip “$z”; done

find -name \*.zip -exec unzip <> \;

find -name \*.zip | xargs -t -i unzip <>

If you like to extract multiple tar or tar.gz use the following command
for f in *.tar.gz; do tar zxf $f; done

Thanks all for sharing, very useful information about Unzip.

Question: and if I want do delete a file in a batch of different compressed archives? Lets say all copies of “info.txt” or “logo.jpg” in a.zip, b.zip, c.zip(…) z.zip, etc. There is a way to do it?

excellent post …. short method is really awesome..

Exactly what I was looking for! THANK YOU!

Time saver, life saver! Thank you!

thanks a lot …..4 help

if u want to display some msg then…

Thanks everyone for the answers. If space is an issue, you can do something like (from some dude) to remove the archive files as they are unpackaged:
for z in *.zip; do unzip $z; rm $z; done

I have 1..10 zip files in one directory …i want to unzip all files at a time..
can any one help how to do that

Thank you very much.

Thank you very much, on my Debian option #2 works very well!

I had a pile of zip that each contained a index.html file and the archive structure had no folder.. They obviously had to be extracted in separate folders so as to not overwrite the so precious files. Since it was a temporary “view and delete” kind of thing and with well over a hundred files (not needing to be unzipped in a specific folder, current folder was just fine), i came up with this;

for z in *.zip; do q=$(echo $z | cut -f 1 -d ‘.’); unzip $z -d ./$q; done;

It basically extracts all the zip files to the current directory, into a folder named after the zip filename. Greatly inspired (if not totally ripped from!) NixCraft and http://stackoverflow.com/questions/12152626/how-can-remove-the-extension-of-a-filename-in-a-shell-script

Couple seconds after i figured “oh well”, i saved that much time so i might as well make something out of it… So instead of just ‘hardcoding’ it into a simple bash alias that doesn’t take parameters, I took a couple more minutes to have it let me at least input a base directory for extraction. Here’s what i came up with (function in .bashrc file);

unzipALL() <
dir=’.’;
[[ ! -z «$<1>» ]] && dir=$1;
for z in *.zip; do
q=$(echo $z | cut -f 1 -d ‘.’);
unzip $z -d $dir/$q;
done;
>

From the command line just use unzipAll to unzip to the current folder or pass it a folder name: unzipAll /tmp extracts all to /tmp/%filename%.

It does perform a single basic check on the passed parameter but nothing too fancy (strip spaces before/after then checks against null). One could spend more time and cutomize it further, adding bad directory check and all that…

I figure i’d share… thanks and hopefuly it can be of use to someone!

I hope i didn’t break any rules posting a url in here, sorry if so heeh

Awesome job and thanks for sharing it with us.

unzip “*.zip” should also be OK.

unzip *.zip does not work in bash.

blah@blahblah:

/tmp-zip$ unzip *.zip
Archive: test1.zip
caution: filename not matched: test2.zip
blah@blahblah:

unzip \*.zip DOES work, still doesn’t solve the problem i faced of multiple same-name files…

blah@blahblah:

/tmp-zip$ unzip \*.zip
[. ]
inflating: index.html
inflating: portfolio.html
inflating: services.html
Archive: test2.zip
replace index.html? [y]es, [n]o, [A]ll, [N]one, [r]ename:

unzip “*.zip” results in the same, btw.

Hence the quick function. If you have a better way please share
Also, while testing you assumptions, i found out that unzip tries to look for .ZIP files on it’s own – pretty neat… unzip \* would work (still not help with the issue…)

I just pulled a lot of files (over 400K) all of them were in zip, i’m trying to make huge archive off free documents at http://uploadcoins.com , so for me worked # unzip \*.zip , all that 400K went ok 🙂 , so again, You can use unzip \*.zip , Good luck

I want a script to extract a particular file from the multiple zip folder.

Источник

How to unzip a multipart (spanned) ZIP on Linux?

I need to upload a 400mb file to my web server, but I’m limited to 200mb uploads. My host suggested I use a spanned archive, which I’ve never done on Linux.

I created a test in its own folder, zipping up a PDF into test.zip.001 , .002 , and .003 . How do I go about unzipping it? Do I need to join them first?

Please note that I’d be just as happy using 7z as I am using ZIP formats. If this makes any difference to the outcome.

10 Answers 10

You will need to join them first. You may use the common linux app, cat as in the example below:

This will concatenate all of your test.zip.001 , test.zip.002 , etc files into one larger, test.zip file. Once you have that single file, you may run unzip test.zip

/hugefile is a directory? What is the purpose of the tilde symbol? Sorry to ask what I suspect are very basic questions.

/hugefile is the same as /home/tim/hugefile. did you split your files ? what are the split files names?

The Linux unzip utility doesn’t really support multipart zips. From the manual:

Multi-part archives are not yet supported, except in conjunction with zip. (All parts must be concatenated together in order, and then zip -F (for zip 2.x) or zip -FF (for zip 3.x) must be performed on the concatenated archive in order to “fix” it. Also, zip 3.0 and later can combine multi-part (split) archives into a combined single-file archive using zip -s- inarchive -O outarchive . See the zip 3 manual page for more information.)

So you need to first concatenate the pieces, then repair the result. cat test.zip.* concatenates all the files called test.zip.* where the wildcard * stands for any sequence of characters; the files are enumerated in lexicographic order, which is the same as numerical order thanks to the leadings zeroes. >test.zip directs the output into the file test.zip .

If you created the pieces by directly splitting the zip file, as opposed to creating a multi-part zip with the official Pkzip utility, all you need to do is join the parts.

Источник

Читайте также:  Откройте редактор реестра windows
Оцените статью