нужно обновить подпапку ZIP - PullRequest
0 голосов
/ 02 мая 2020

У меня есть zip-файл

# unzip -l 2020-05-01.zip 
1561  05-02-2020 01:22   zzz/text.csv

Я хочу добавить файл b.txt в zzz папку

Я пробую это

zip -ur 2020-05-01.zip b.txt

Это добавляет b.txt в root папку 2020-05-01.zip

Я пробую несколько случайных вещей, но не получаю много ...

Любая идея, как я могу сделать эту работу сделано ...

желаемый вывод

# unzip -l 2020-05-01.zip 

zzz/text.csv
zzz/b.txt

Ответы [ 2 ]

0 голосов
/ 02 мая 2020

Вы проверили почтовик? Linux ZIP человек

Абзац:

Command format. The basic command format is

zip options archive inpath inpath ...
where archive is a new or existing zip archive and inpath is a directory or file path optionally including wildcards. When given the name of an existing zip archive, zip will replace identically named entries in the zip archive (matching the relative names as stored in the archive) or add entries for new names. For example, if foo.zip exists and contains foo/file1 and foo/file2, and the directory foo contains the files foo/file1 and foo/file3, then:
zip -r foo.zip foo
or more concisely
zip -r foo foo
will replace foo/file1 in foo.zip and add foo/file3 to foo.zip. After this, foo.zip contains foo/file1, foo/file2, and foo/file3, with foo/file2 unchanged from before.
So if before the zip command is executed foo.zip has:

foo/file1 foo/file2
and directory foo has:
file1 file3
then foo.zip will have:
foo/file1 foo/file2 foo/file3
where foo/file1 is replaced and foo/file3 is new.

В основном, что вам нужно сделать, чтобы поместить b.txt в zzz каталог

zip -ur 2020-05-01.zip zzz/b.txt

Он будет добавлен в zzz/b.txt или заменит файл, если он уже существует.

0 голосов
/ 02 мая 2020

Как сказал @Poshi в комментариях.

mkdir zzz
mv b.txt zzz
zip -u 2020-05-01.zip zzz/b.txt

это решило проблему для меня. Это тоже для тебя?

...