I have a folder of around 180 GBs, I need to zip it like:
zip -p password /Volumes/GGZ/faster/mybigfolder/* /Volumes/Storage\ 4/archive.zip
But it says:
zip warning: name not matched: /Volumes/Storage 4/archive.zip
So how do I do this? On another note, archive.zip
does not exist, but I’m trying to create it.
Braiam
35.5k26 gold badges108 silver badges167 bronze badges
asked Jan 16, 2015 at 14:12
DisplayNameDisplayName
11.5k20 gold badges73 silver badges115 bronze badges
1
This error can also be caused by symbolic links in the directory tree being compressed.
If these don’t have correct destinations (perhaps because the directory has been moved or copied from elsewhere), zip will attempt to follow the symlink to archive the target file.
You can avoid this (and also get the effect you probably want anyway, which is not to archive multiple copies of the file) by using the -y
(or --symlinks
) option.
Eddie C.
4254 silver badges7 bronze badges
answered Jul 7, 2017 at 8:42
1
Your command should be:
zip -p password -r /Volumes/Storage\ 4/archive.zip /Volumes/GGZ/faster/mybigfolder/
The manual page (man zip
), shows you should have:
zip <options> <archive> <inpath...>
Also, the -r
option for recursion is highly recommended over the «*» shell glob for this.
answered Jan 16, 2015 at 14:28
Danny StapleDanny Staple
2,1411 gold badge15 silver badges22 bronze badges
1
Use the recursive flag (-r
) instead of glob (*
) to match files to compress. In addition, specify the archive name first and then give the list of files:
zip -p password -r /Volumes/Storage\ 4/archive.zip /Volumes/GGZ/faster/mybigfolder/
answered Feb 5, 2019 at 9:05
I’ve also got this error in the past for a different reason which the -r
switch cannot fix. What happened is that I based files to add to the zip with the following bash code/variable
somevar=`ls -1 somedir`
The problem is that ls
just lists the files off as if it were in the current directory and this is why zip
is complaining (essentially the files do not exist to zip because it is being told to look in the wrong/current directory).
If this is your issue you can correct it like so:
somevar=`ls -1d somedir/*`
As you can see I used the -d
switch and also /*
at the end of the directory name and then the files were successfully added.
Eddie C.
4254 silver badges7 bronze badges
answered Apr 24, 2017 at 6:08
1
You must log in to answer this question.
Not the answer you’re looking for? Browse other questions tagged
.
Not the answer you’re looking for? Browse other questions tagged
.
I have a folder of around 180 GBs, I need to zip it like:
zip -p password /Volumes/GGZ/faster/mybigfolder/* /Volumes/Storage\ 4/archive.zip
But it says:
zip warning: name not matched: /Volumes/Storage 4/archive.zip
So how do I do this? On another note, archive.zip
does not exist, but I’m trying to create it.
Braiam
35.5k26 gold badges108 silver badges167 bronze badges
asked Jan 16, 2015 at 14:12
DisplayNameDisplayName
11.5k20 gold badges73 silver badges115 bronze badges
1
This error can also be caused by symbolic links in the directory tree being compressed.
If these don’t have correct destinations (perhaps because the directory has been moved or copied from elsewhere), zip will attempt to follow the symlink to archive the target file.
You can avoid this (and also get the effect you probably want anyway, which is not to archive multiple copies of the file) by using the -y
(or --symlinks
) option.
Eddie C.
4254 silver badges7 bronze badges
answered Jul 7, 2017 at 8:42
1
Your command should be:
zip -p password -r /Volumes/Storage\ 4/archive.zip /Volumes/GGZ/faster/mybigfolder/
The manual page (man zip
), shows you should have:
zip <options> <archive> <inpath...>
Also, the -r
option for recursion is highly recommended over the «*» shell glob for this.
answered Jan 16, 2015 at 14:28
Danny StapleDanny Staple
2,1411 gold badge15 silver badges22 bronze badges
1
Use the recursive flag (-r
) instead of glob (*
) to match files to compress. In addition, specify the archive name first and then give the list of files:
zip -p password -r /Volumes/Storage\ 4/archive.zip /Volumes/GGZ/faster/mybigfolder/
answered Feb 5, 2019 at 9:05
I’ve also got this error in the past for a different reason which the -r
switch cannot fix. What happened is that I based files to add to the zip with the following bash code/variable
somevar=`ls -1 somedir`
The problem is that ls
just lists the files off as if it were in the current directory and this is why zip
is complaining (essentially the files do not exist to zip because it is being told to look in the wrong/current directory).
If this is your issue you can correct it like so:
somevar=`ls -1d somedir/*`
As you can see I used the -d
switch and also /*
at the end of the directory name and then the files were successfully added.
Eddie C.
4254 silver badges7 bronze badges
answered Apr 24, 2017 at 6:08
1
You must log in to answer this question.
Not the answer you’re looking for? Browse other questions tagged
.
Not the answer you’re looking for? Browse other questions tagged
.
I am getting the following error while using zip in my bash script
zip warning: name not matched: test.png test2.png
#!/bin/bash
files_to_zip="test.png test2.png"
zipfile_name=result$(date "+%Y.%m.%d-%H.%M.%S").zip
zip "$zipfile_name" "$files_to_zip"
Note: The images are in the same directory as the script and when i execute zip test.zip test.png test2.png
, the zip get created just fine.
- bash
- unix
- zip
asked Sep 2, 2017 at 15:13
user2650277user2650277
6,32917 gold badges63 silver badges132 bronze badges
9
-
If you substitute your vars into command you’ll get
zip "result-2017-09-02.zip" "test.png test2.png"
this is different from what you want to achieveSep 2, 2017 at 15:18
-
The name of the zip is an example , i use
test.zip
for simplicitySep 2, 2017 at 15:21
-
I mean your last parameter goes into same «» so is treated as one file name which will not be found
Sep 2, 2017 at 15:22
-
@Artemy Vysotsky but
$files_to_zip
contain list of files as a string separated by spaces so zip should know they are different filenamesSep 2, 2017 at 15:29
-
Why you have not tried
zip test.zip "test.png test2.png"
? If you sure zip has to understand itSep 2, 2017 at 15:31
1 Answer
When names are combined inside same quotes whole string is treated as file name. Use
zip "$zipfile_name" $files_to_zip
instead. And if your png names have special characters like spaces — add quotes or escape this characters inside the $files_to_zip
variable
answered Sep 2, 2017 at 16:05
Я пытаюсь заархивировать файл с помощью команды сценария оболочки. Я использую следующую команду:
zip ./test/step1.zip $FILES
где $FILES содержит все входные файлы. Но я получаю предупреждение следующим образом
zip warning: name not matched: myfile.dat
и еще одна вещь, которую я заметил, что у файла, который наконец находится в списке файлов в папке, есть вышеупомянутое предупреждение, и этот файл не получает сжатый.
Может кто-нибудь объяснить мне, почему это происходит? Я новичок в мире сценариев оболочки.
2013-12-11 21:02
6
ответов
zip предупреждение: имя не совпадает: myfile.dat
Это означает, что файл myfile.dat
не существует.
Вы получите ту же ошибку, если файл является символической ссылкой, указывающей на несуществующий файл.
Как вы говорите, каким бы ни был последний файл на $FILES
, он не будет добавлен в почтовый индекс вместе с предупреждением. Поэтому я думаю, что что-то не так с тем, как вы создаете $FILES
, Скорее всего, в конце последнего имени файла есть символ новой строки, возврата каретки, пробела, табуляции или другого невидимого символа, в результате чего чего-то не существует. Попробуйте это например:
for f in $FILES; do echo :$f:; done
Бьюсь об заклад, последняя строка будет неправильной, например:
:myfile.dat :
… или что-то подобное вместо :myfile.dat:
без символов до последнего :
ОБНОВИТЬ
Если вы говорите, что скрипт начал работать после запуска dos2unix
на это, что подтверждает то, что все уже подозревали, что каким-то образом был возврат каретки в конце вашего $FILES
список.
od -c
показывает возврат каретки. Пытаться echo $FILES | od -c
2013-12-11 21:05
Другая возможная причина, которая может генерировать zip warning: name not matched:
ошибка имеет какой-либо из zip
Переменные среды установлены неправильно.
Со страницы руководства:
ENVIRONMENT
The following environment variables are read and used by zip as described.
ZIPOPT
contains default options that will be used when running zip. The contents of this environment variable will get added to the command line just after the zip command.
ZIP
[Not on RISC OS and VMS] see ZIPOPT
Zip$Options
[RISC OS] see ZIPOPT
Zip$Exts
[RISC OS] contains extensions separated by a : that will cause native filenames with one of the specified extensions to be added to the zip file with basename and extension swapped.
ZIP_OPTS
[VMS] see ZIPOPT
В моем случае я использовал zip
в скрипте и имел двоичное расположение в переменной окружения ZIP
чтобы мы могли перейти на другой zip
двоичный файл легко, не внося тонны изменений в сценарии.
Пример:
ZIP=/usr/bin/zip
...
${ZIP} -r folder.zip folder
Затем это обрабатывается как:
/usr/bin/zip /usr/bin/zip -r folder.zip folder
И генерирует ошибки:
zip warning: name not matched: folder.zip
zip I/O error: Operation not permitted
zip error: Could not create output file (/usr/bin/zip.zip)
Первый, потому что сейчас пытается добавить folder.zip
в архив, а не использовать его в качестве архива. Второй и третий, потому что он пытается использовать файл /usr/bin/zip.zip
как архив, который (к счастью) не доступен для записи обычному пользователю.
Примечание. Это действительно старый вопрос, но я нигде не нашел этого ответа, поэтому я публикую его, чтобы помочь будущим поисковикам (включая мое будущее).
2017-04-03 01:11
eebbesen ударил по гвоздю в своем комментарии к моему делу (но я не могу голосовать за комментарий). Другая возможная причина, пропущенная в других комментариях, — файл, превышающий ограничение размера файла (4 ГБ).
2015-04-07 14:42
Я преобразовал свой сценарий для среды Unix с помощью команды dos2unix и выполнил мой сценарий как./myscript.sh вместо bash myscript.sh.
2013-12-11 22:23
Я тоже столкнулся с этой проблемой. В моем случае отдельная строка — это CRLF в моем сценарии оболочки zip, что вызывает проблему. Использование LF исправило это.
2020-04-11 08:58
Пробелы не допускаются:
он потерпит неудачу, если в $FILES будет несколько файлов, если вы не поместите их в цикл
2014-04-18 00:21
Я только что обнаружил другую потенциальную причину для этого. Если разрешения каталога / подкаталога не позволяют zip-файлу найти файл, он сообщит об этой ошибке. На самом деле, если вы запустите chmod -R 444 в каталоге, а затем попытаетесь сжать его, вы воспроизведете эту ошибку, а также получите отчет «сохранено 0%», например:
zip предупреждение: имя не соответствует: добавление borrar / enviar: borrar/ (сохранено 0%)
Следовательно, попробуйте изменить права доступа к файлу. Если вы пытаетесь отправить их по электронной почте, и эти почтовые фильтры (например, Gmail) изобретают глупые фильтры отсутствия отправки исполняемых файлов, не забывайте, что очень строгие разрешения при сжатии zip могут быть причиной сообщаемой вами ошибки, «имя не соответствует».
2014-09-29 14:56
Various pattern rules can be utilized to generate the same target, such as a C source file, C++ source file, FORTRAN source file, and so on. In the case where names are merged within the same quotes, the entire string is treated as a file name.
Zip warning — name not matched
Question:
While utilizing zip in my bash script, I am encountering the subsequent error.
zip warning: name not matched: test.png test2.png
#!/bin/bash
files_to_zip="test.png test2.png"
zipfile_name=result$(date "+%Y.%m.%d-%H.%M.%S").zip
zip "$zipfile_name" "$files_to_zip"
Please note that the images are located in the script’s directory and the zip file is successfully created when executing
zip test.zip test.png test2.png
.
Solution:
When multiple names are enclosed within the same quotation marks, the entire string is considered as a file name. Utilize this method.
zip "$zipfile_name" $files_to_zip
In case your
png names
contains special characters such as spaces, it is advisable to either enclose them in quotes or escape these characters within the
$files_to_zip
variable instead.
File matching patterns reference, Match characters. Most characters are used as exact matches. What counts as an «exact» match is platform-dependent: the Windows filesystem is case-insensitive, so the pattern «ABC» would match a file called «abc». On case-sensitive filesystems, that pattern and name would not match. The following characters …
Unix & Linux: «zip warning: name not matched» while
Unix & Linux: »
zip warning: name not matched»
while compressing a directory
(4
Solutions!)Helpful? Please support me on Patreon: https:
Zip command show warnings «name not matched» about
Unix & Linux:
zip
command show
warnings
»
name not matched
» about symlinks, outside of my working directory, pointing to non-existing targetHelpful? Please s
Zip warning name not matched
About
Press Copyright
Contact us Creators Advertise Developers Terms Privacy Policy & Safety How YouTube works Test new features
Press Copyright
Contact us …
Zip error after 7-zip install and uninstall
Question:
Operating in Cygwin on Windows 10, I encountered an error while utilizing zip on the command line in Cygwin after installing and subsequently uninstalling 7-Zip. This error arises whenever I attempt to zip any files.
zip warning: name not matched: Files\7-zip
zip warning: name not matched: testing
E.g. zipping 2 files a and b:
zip testing a b
Encountering the error, how can I eliminate this annoyance? Unfortunately, reinstalling the zip file did not provide a solution.
Solution:
Following an extensive search that yielded no answers, I eventually discovered the cause of the problem.
7-Zip creates an environment variable named
\
\ \ \ \ ZIP=C:\Program\ Files\7\-zip\
\ \ \
which, for unknown reasons, causes a conflict with the GNU zip utility when there is a
ZIP variable
present.
To remove ZIP, I performed
ctrl-Esc
and entered
env
. This action displayed the control panel option »
Edit environment variables
for your account,» allowing me to eliminate the ZIP variable and restore functionality.
How to create a file to test Zip Slip Vulnerability, The contents of this zip file have to be hand crafted. Archive creation tools don’t typically allow users to add files with these paths, despite the zip specification allowing it. However, with the right tools, it’s easy to create files with these paths. I want to create a test payload so that i can check few of my zip …
How to create a file to test Zip Slip Vulnerability from commandline
Question:
The vulnerability can be found at https://snyk.io/research/
zip-slip
.
Users are required to manually create the contents of this zip file. Although the zip specification permits it, most archive creation tools do not allow the addition of files with such paths. Nevertheless, it is simple to create files with these paths using the appropriate tools.
I am looking to generate a test payload in order to verify my zip handling logic, but I am unable to find any guidance on how to do so.
:~/Desktop # touch "../../../../../../../../tmp/evil.sh"
:~/Desktop # ll
:~/Desktop # ll /tmp/evil.sh
-rw-r--r-- 1 root root 0 Jun 14 09:27 /tmp/evil.sh
Solution:
Maybe
zip zipslip.zip ../../../../../../../../tmp/evil.sh
Working With Zip Command in Linux, We can see that the zip command prints a warning, telling us the archive total-new-archive.zip is not found. Nevertheless, it creates and puts the bank-accounts.txt and customer-details.txt into the archive. 6. Encrypting an Archive The zip command allows us to encrypt an archive using the flag -e.
Issue with make
Question:
In this small example, everything should function properly if we exclude the occurrence of
VILLAIN
. Surprisingly, this term causes an error, although not in the location I anticipated…
The error:
$ make
mkdir -p obj
zip out.exe obj/foo.o obj/bar.o obj/baz.o
zip warning: name not matched: obj/foo.o
zip warning: name not matched: obj/bar.o
zip warning: name not matched: obj/baz.o
zip error: Nothing to do! (out.exe)
Makefile:9: recipe for target 'out.exe' failed
make: *** [out.exe] Error 12
Make appears to be attempting to progress too quickly by executing a recipe without ensuring that its dependencies (obj/foo.o …) have been created. In fact, I anticipated receiving an error message such as: «Unable to locate VILLAIN for generating obj/foo.o».
The Makefile:
#!/usr/bin/env make
SRCDIR = src
OBJDIR = obj
SRC = $(addsuffix .c,foo bar baz)
OBJ = $(addprefix $(OBJDIR)/, $(notdir $(SRC:c=o)))
out.exe: $(OBJ)
zip $@ $^
$(OBJDIR)/%.o: $(SRCDIR)/%.c VILLAIN
cp $< $@
$(OBJ) : | $(OBJDIR)
$(OBJDIR):
mkdir -p $@
clean:
rm -f *.c
rm -rf $(OBJDIR)/ $(SRCDIR)/
mkdir -p $(SRCDIR)/
touch $(addprefix $(SRCDIR)/,$(SRC))
Nevertheless, the removal of the antagonist results in smooth operation.
$ make clean
rm -f *.c
rm -rf obj/ src/
mkdir -p src/
touch src/foo.c src/bar.c src/baz.c
$ make
mkdir -p obj
cp src/foo.c obj/foo.o
cp src/bar.c obj/bar.o
cp src/baz.c obj/baz.o
zip out.exe obj/foo.o obj/bar.o obj/baz.o
adding: obj/foo.o (stored 0%)
adding: obj/bar.o (stored 0%)
adding: obj/baz.o (stored 0%)
Why attempt to establish a goal without first constructing the necessary foundation?
Solution:
In terms of this aspect,
Pattern rules
operates differently than
explicit rule
. Numerous variations of
pattern rules
could be utilized to achieve the same objective (for example, a
.o
can be generated from a C source file, a C++ source file, and so on).
When attempting to identify a pattern rule to construct a target, make will attempt to build all the prerequisites to determine if the pattern matches. If one of the prerequisites cannot be constructed, it is not considered an error. Make will simply move on to the next matching pattern rule and attempt that. Therefore, the absence of
VILLIAN
and its inability to be constructed signifies that make will never choose this pattern rule due to unsatisfactory prerequisites. It is important to note that this is not an error, and no message will be displayed (unless observed in make’s debug output).
In the process of building
obj/foo.o
, it will be noticed that there are no existing rules in place. Normally, one would anticipate an error at this stage, but due to the addition of a specific rule, no error will occur.
$(OBJ) : | $(OBJDIR)
By declaring
obj/foo.o
as a target, you inform the make system about it, preventing any complaints regarding the non-existence of the target. To enhance clarity, consider including the order-only prerequisite in the pattern rule.
$(OBJDIR)/%.o: $(SRCDIR)/%.c VILLAIN | $(OBJDIR)
cp $< $@
$(OBJDIR):
mkdir -p $@
Gives:
make: *** No rule to make target 'obj/foo.o', needed by 'out.exe'. Stop.
Pset5 — Zip error pset 5, Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site