The Linux zip warning name not matched means the command’s file-selection pattern did not match any file or directory that zip could find at the path it searched. It usually indicates a typo, an unexpected working directory, or a glob that matched nothing—not a problem with the ZIP format itself.
What the warning means
When you run a command such as zip archive.zip report.txt, zip looks for report.txt relative to the current directory, unless you provide a path. If there is no matching entry, it prints a warning like zip warning: name not matched: report.txt. The archive may still be created, but the unmatched item is not added.
This distinction matters: a ZIP file existing afterward does not prove that it contains the files you intended. If every requested name fails to match, you may end up with an empty archive or an archive without the expected content. Check the command’s output and inspect the result rather than treating the warning as harmless.
Check the path and current directory
Linux resolves relative paths from the command’s current working directory, not necessarily from the directory where the script or ZIP file is located. Use pwd to see your current location and ls to check what is there. Then either change to the correct directory or provide the file’s path.
- If the file is in the current directory:
zip backup.zip report.txt - If it is in a subdirectory:
zip backup.zip documents/report.txt - If the name contains spaces:
zip backup.zip "quarterly report.txt" - If you want to include a directory and its contents:
zip -r backup.zip documents/
Linux filenames are case-sensitive. Report.txt, report.txt, and REPORT.txt are different names. Also look for hidden differences such as an extra space, a different extension, or punctuation. To see a filename’s exact spelling, list the directory or use shell completion by pressing Tab after typing part of the path.
How shell wildcards affect zip
A common cause is a wildcard such as *.log. In many shells, including Bash, the shell expands an unquoted wildcard before starting zip. If there are matching files, the program receives their actual names. If there are none, Bash normally leaves the pattern unchanged, so zip receives the literal argument *.log and reports that it did not match.
For example, if a directory has no log files, this command can produce the warning:
zip logs.zip *.log
Confirm that the pattern matches before running the command:
printf '%s\n' *.log
If the output is literally *.log, the shell did not find a match. If your shell is configured to raise an error for unmatched wildcards, such as Bash with nullglob or failglob enabled, behavior can differ. A wildcard in a quoted argument, like "*.log", is not expanded by the shell; whether it is treated as a pattern then depends on how zip handles that argument and its options.
Use recursive options and file lists correctly
The -r option tells zip to descend into directories. Without it, naming a directory does not generally mean “add everything underneath.” For example, use zip -r site.zip public/ to include a directory tree. If you want only selected files from a tree, use a suitable path or pattern and verify the resulting archive.
For a list of files, zip can read names from standard input with -@, one name per line. For instance:
find documents -type f -name '*.txt' -print | zip notes.zip -@
Here the quotes around '*.txt' prevent the shell from expanding the pattern; find applies it instead. This approach is useful when filenames contain spaces, but newline characters in filenames make line-based lists ambiguous. For scripts that must handle arbitrary filenames, use a null-delimited workflow with tools and options designed to support it, rather than assuming every filename can safely be represented as one line.
Common mistakes and how to diagnose them
- Running the command from the wrong directory: use
pwd, then provide the correct relative or absolute path. - Misspelling or capitalization mismatch: copy the exact name shown by
ls; Linux treats capitalization as significant. - Assuming a wildcard matched files: test it with
printf '%s\n' patternor inspect the directory first. - Forgetting recursive mode: add
-rwhen archiving a directory tree. - Confusing ZIP patterns with shell patterns: shell expansion happens before
zipruns, while ZIP’s own include or exclude options have their own pattern rules. - Using a list with unexpected paths: check whether listed names are relative to the directory from which the command is run.
To see what was actually archived, run unzip -l archive.zip. You can also test archive integrity with unzip -t archive.zip. These commands help distinguish a selection problem from a damaged archive. If the warning appears in a script, print or log the working directory and the arguments being passed to zip; scripts often run from a different directory than expected.
Related warnings and practical checks
name not matched is about a requested input that could not be selected. It is not the same as an error saying the archive could not be written, a permission-denied message, or a warning about an existing archive entry. Those point to different issues, such as destination permissions, disk space, or duplicate names.
Before relying on an archive, use a simple check sequence:
- Confirm the source exists with
ls -l -- path. - Check the directory with
pwdand correct the path or working directory. - Test any wildcard and quote filenames containing spaces.
- Rerun
zipand read all warnings. - List the archive with
unzip -land test it withunzip -t.
Options and exact warning wording can vary among implementations and versions, so consult man zip on the system where the command runs. The central diagnostic remains the same: identify the exact name or pattern that did not match, then verify how the shell and zip interpreted it.
Frequently Asked Questions
Does “name not matched” mean the ZIP file is corrupted?
No. It means an input name did not match a file or directory during selection. The archive may be valid but incomplete, so inspect it with unzip -l and unzip -t.
Why does zip warn about *.txt when I can see text files?
You may be running the command from another directory, or the visible files may have different capitalization or extensions. Check pwd, list the directory, and test the pattern in the same shell and location where you run zip.
How do I zip a folder and everything inside it?
Use recursive mode, for example zip -r backup.zip folder/. Without -r, the command may not add the directory tree as intended.
Can I ignore the warning if the archive was created?
Only if you have confirmed the unmatched name was not needed. A created archive can omit requested files. List its contents and verify that every required item is present.
How do I include a filename with spaces?
Quote the path, as in zip backup.zip "my report.txt". Quoting keeps the shell from splitting the filename into separate arguments.