unzip и wildcard (Лыжи не едут)

На самом деле это единственный раздел про unix на этом форуме

Модераторы: /dev/random, Модераторы разделов

Аватара пользователя
Bizdelnick
Модератор
Сообщения: 21251
Статус: nulla salus bello
ОС: Debian GNU/Linux

unzip и wildcard

Сообщение Bizdelnick »

Дано: куча файлов в нескольких zip-архивах.
Задача: распаковать их в одну папку.
Очевидное, казалось бы, решение:

Код: Выделить всё

unzip *.zip -d /media/disk/Books

Результат:

Код: Выделить всё

bash-3.2$ unzip *.zip -d /media/disk/Books
Archive:  101016-102097.zip
caution: filename not matched:  1010-2042.zip
caution: filename not matched:  10168-11189.zip
caution: filename not matched:  102098-103203.zip
caution: filename not matched:  103204-103700.zip
caution: filename not matched:  103701-104805.zip
caution: filename not matched:  104807-105902.zip
caution: filename not matched:  105903-107047.zip
caution: filename not matched:  107048-107191.zip
caution: filename not matched:  107194-108295.zip
caution: filename not matched:  108296-109376.zip
caution: filename not matched:  109377-110395.zip
caution: filename not matched:  1-1009.zip
caution: filename not matched:  110396-111600.zip
caution: filename not matched:  111601-112396.zip
caution: filename not matched:  11190-12191.zip
caution: filename not matched:  112398-113759.zip
caution: filename not matched:  113760-114986.zip
caution: filename not matched:  114987-115986.zip
caution: filename not matched:  115987-116987.zip
caution: filename not matched:  116988-117987.zip
caution: filename not matched:  117988-118987.zip
caution: filename not matched:  118988-119751.zip
caution: filename not matched:  119752-121101.zip
caution: filename not matched:  121102-122247.zip
caution: filename not matched:  12192-13222.zip
caution: filename not matched:  122248-123010.zip
caution: filename not matched:  123011-124604.zip
caution: filename not matched:  124605-125463.zip
caution: filename not matched:  125473-126782.zip
caution: filename not matched:  126783-129609.zip
caution: filename not matched:  129610-131221.zip
caution: filename not matched:  131222-131486.zip
caution: filename not matched:  131487-132658.zip
caution: filename not matched:  13223-14247.zip
caution: filename not matched:  132659-133498.zip
caution: filename not matched:  133502-134893.zip
caution: filename not matched:  134894-136118.zip
caution: filename not matched:  136119-137572.zip
caution: filename not matched:  137573-138420.zip
caution: filename not matched:  138421-139848.zip
caution: filename not matched:  139850-140188.zip
caution: filename not matched:  14248-15259.zip
caution: filename not matched:  15260-16266.zip
caution: filename not matched:  16267-17314.zip
caution: filename not matched:  17315-18445.zip
caution: filename not matched:  18446-19463.zip
caution: filename not matched:  19464-20467.zip
caution: filename not matched:  2043-3049.zip
caution: filename not matched:  20468-21473.zip
caution: filename not matched:  21474-22498.zip
caution: filename not matched:  22499-23503.zip
caution: filename not matched:  23504-24507.zip
caution: filename not matched:  24508-25525.zip
caution: filename not matched:  25526-26538.zip
caution: filename not matched:  26539-27572.zip
caution: filename not matched:  27573-28578.zip
caution: filename not matched:  28579-29584.zip
caution: filename not matched:  29585-30587.zip
caution: filename not matched:  3050-4051.zip
caution: filename not matched:  30588-31598.zip
caution: filename not matched:  31599-32657.zip
caution: filename not matched:  32658-33689.zip
caution: filename not matched:  33690-34694.zip
caution: filename not matched:  34695-35735.zip
caution: filename not matched:  35736-36746.zip
caution: filename not matched:  36747-37763.zip
caution: filename not matched:  37764-38767.zip
caution: filename not matched:  38768-39771.zip
caution: filename not matched:  39772-40803.zip
caution: filename not matched:  4052-5081.zip
caution: filename not matched:  40804-41813.zip
caution: filename not matched:  41814-42838.zip
caution: filename not matched:  42839-43882.zip
caution: filename not matched:  43883-44892.zip
caution: filename not matched:  44893-45936.zip
caution: filename not matched:  45937-46943.zip
caution: filename not matched:  46944-47972.zip
caution: filename not matched:  47973-48985.zip
caution: filename not matched:  48986-49986.zip
caution: filename not matched:  49987-50989.zip
caution: filename not matched:  5082-6090.zip
caution: filename not matched:  50990-51991.zip
caution: filename not matched:  51992-53009.zip
caution: filename not matched:  53010-54048.zip
caution: filename not matched:  54049-55107.zip
caution: filename not matched:  55108-56111.zip
caution: filename not matched:  56112-57126.zip
caution: filename not matched:  57127-58134.zip
caution: filename not matched:  58135-59181.zip
caution: filename not matched:  59182-60190.zip
caution: filename not matched:  60191-61195.zip
caution: filename not matched:  6091-7092.zip
caution: filename not matched:  61196-62215.zip
caution: filename not matched:  62216-66717.zip
caution: filename not matched:  66718-67726.zip
caution: filename not matched:  67727-68750.zip
caution: filename not matched:  68751-69765.zip
caution: filename not matched:  69766-70769.zip
caution: filename not matched:  70770-71780.zip
caution: filename not matched:  7093-8103.zip
caution: filename not matched:  71781-72791.zip
caution: filename not matched:  72792-73804.zip
caution: filename not matched:  73805-74830.zip
caution: filename not matched:  74831-75834.zip
caution: filename not matched:  75835-76841.zip
caution: filename not matched:  76842-77844.zip
caution: filename not matched:  77845-78863.zip
caution: filename not matched:  78864-79877.zip
caution: filename not matched:  79878-80920.zip
caution: filename not matched:  80921-81967.zip
caution: filename not matched:  8104-9134.zip
caution: filename not matched:  81968-89659.zip
caution: filename not matched:  89660-92360.zip
caution: filename not matched:  9135-10167.zip
caution: filename not matched:  92361-93397.zip
caution: filename not matched:  93398-94670.zip
caution: filename not matched:  94671-95816.zip
caution: filename not matched:  95817-96935.zip
caution: filename not matched:  96936-98033.zip
caution: filename not matched:  98058-98693.zip
caution: filename not matched:  98696-99339.zip
caution: filename not matched:  99340-101013.zip

Что не так?
Пишите правильно:
в консоли
вку́пе (с чем-либо)
в общем
вообще
в течение (часа)
новичок
нюанс
по умолчанию
приемлемо
проблема
пробовать
трафик
Спасибо сказали:
Аватара пользователя
/dev/random
Администратор
Сообщения: 5404
ОС: Gentoo

Re: unzip и wildcard

Сообщение /dev/random »

unzip за один раз работает только с одним архивом. Если имён файлов больше, то остальные он воспринимает как имена файлов внутри архива, которые надо оттуда извлечь.

ls *.zip | xargs -i -d$'\n' unzip '{}'

Если вы уверены, что в именах файлов нет бакслэшей, кавычек и прочего, то можно короче:

ls *.zip | xargs -i unzip '{}'
Спасибо сказали:
Аватара пользователя
Bizdelnick
Модератор
Сообщения: 21251
Статус: nulla salus bello
ОС: Debian GNU/Linux

Re: unzip и wildcard

Сообщение Bizdelnick »

/dev/random писал(а):
03.12.2009 21:36
unzip за один раз работает только с одним архивом. Если имён файлов больше, то остальные он воспринимает как имена файлов внутри архива, которые надо оттуда извлечь.

ls *.zip | xargs -i -d \n' unzip '{}'

Если вы уверены, что в именах файлов нет бакслэшей, кавычек и прочего, то можно короче:

ls *.zip | xargs -i unzip '{}'

Спасибо!
В мане, выходит, брешут...
ARGUMENTS
file[.zip]
Path of the ZIP archive(s). If the file specification is a
wildcard, each matching file is processed in an order determined
by the operating system (or file system).
Пишите правильно:
в консоли
вку́пе (с чем-либо)
в общем
вообще
в течение (часа)
новичок
нюанс
по умолчанию
приемлемо
проблема
пробовать
трафик
Спасибо сказали:
pcodr
Сообщения: 283
ОС: Debian

Re: unzip и wildcard

Сообщение pcodr »

В мане, выходит, брешут...


Нет, wildcard нужно заключать в кавычки, иначе он интерпретируется шеллом, а не анзипом: unizp '*.zip'
remote system type is unix
Спасибо сказали:
Аватара пользователя
Bizdelnick
Модератор
Сообщения: 21251
Статус: nulla salus bello
ОС: Debian GNU/Linux

Re: unzip и wildcard

Сообщение Bizdelnick »

pcodr писал(а):
04.12.2009 12:16
В мане, выходит, брешут...


Нет, wildcard нужно заключать в кавычки, иначе он интерпретируется шеллом, а не анзипом: unizp '*.zip'

Спасибо, буду знать.
Пишите правильно:
в консоли
вку́пе (с чем-либо)
в общем
вообще
в течение (часа)
новичок
нюанс
по умолчанию
приемлемо
проблема
пробовать
трафик
Спасибо сказали: