- Как разархивировать многочастный (составной) ZIP на Linux?
- How do I unzip multiple / many files under Linux?
- The problem with multiple zip files on Linux
- #1: Unzip Multiple Files Using Single Quote (short version)
- #2: Unzip Multiple Files from Linux Command Line Using Shell For Loop (Long Version)
- How to Simultaneously Unzip or Unrar Multiple Files in Linux
- Unzip Multiple Files at Once
- Extract multiple tar.xz files at Once
- Unrar Multiple Files at Once
- Extract Multiple 7z files at Once
- Karim Buzdar
Как разархивировать многочастный (составной) 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
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 Simultaneously Unzip or Unrar Multiple Files in Linux
At times we have to extract multiple zipped and rar’d files at once, all located in a single folder. Doing so through the Ubuntu UI is fairly simple; all you need to do is select all the files you want to extract, right-click and use the Extract option to extract them altogether. The real deal is when we want to do the same task through the command line. It can prove to be quite lengthy, and frankly illogical, to extract them individually by entering the file extraction commands one by one. Here comes the bash for loop to rescue. You can use it to perform multiple similar operations at once.
This article describes how you can use the for loop to extract multiple files of the following type through the Ubuntu command line:
- Zip files
- Tar.xz files
- Rar files
- 7z files
We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system. Our sample zip and tar folders contain 4 compressed files of zipped and rar’d file types respectively. We are using the Terminal application for using Ubuntu command line. You can open it through the system Dash or the Ctrl+alt+T shortcut.
Unzip Multiple Files at Once
Let us suppose that a folder, a “zip_files” folder in our case, contains multiple zipped files and we want to extract them simultaneously.
Here is how you can use the for loop to make the task simple:
Here is how you can achieve the same task through one single command:
Extract multiple tar.xz files at Once
Let us suppose that a folder contains multiple tar.xz files and we want to extract them simultaneously.
Here is how you can use the for loop to make the task simple:
Here is how you can achieve the same task through one single command:
Unrar Multiple Files at Once
Use the following command in order to unrar multiple rar files at once. Advertisement
Extract Multiple 7z files at Once
Use the following command in order to extract multiple 7z files at once.
Through the use of the bash for loop, you can make the hectic task of extracting multiple compressed files at once. This small skill you learned in this article comes especially handy when we have to extract as much as hundreds of compressed files simultaneously. Not only for file extraction, but you can also use the power of the for loop to perform various other similar tasks that can take longer when you run them one by one.
Karim Buzdar
About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn
Источник