-- (Stop switches parsing) switch
Disables switch parsing after "--" on the command line.
Also it disables parsing of @listfile as list files.
This is to allow 7-Zip to use file names that start with "-" and "@".
Syntax
--
Examples
7z t -- -ArchiveName.7z
tests -ArchiveName.7z archive.
Notes from this site
Not part of the 7-Zip manual. Written by this site; examples checked with 7-Zip 26.04.
How do I use a file name that starts with - or @? Ordering rule
Simplest fix for a file name: write ./-x.txt instead. Otherwise put every switch before --. After it come the archive name and the file names, taken literally as names (wildcards such as '*.txt' still work). The official Linux/macOS console binary is 7zz; on Windows use 7z.
# archive named -Arch.7z that contains a file named -x.txt
7zz a -mx=9 -- -Arch.7z -x.txt
7zz t -- -Arch.7z
# list, and extract only -x.txt
7zz l -- -Arch.7z
7zz x -- -Arch.7z -x.txt
# extract to a folder: -o goes BEFORE --
7zz x -oout -- -Arch.7z
# a file literally named @notes.txt (not a list file)
7zz a -- at.7z @notes.txt
# without --, @list.txt is read as a list of file names
7zz a lst.7z @list.txt
In our tests the first command stored -x.txt, the test printed "Everything is Ok", the extract wrote only -x.txt, the @notes.txt entry was stored by name, and the last command stored the files named inside list.txt.
Common mistakes
A switch after -- becomes a file name. 7zz a -- a.7z real.txt -r printed "No such file or directory" for -r, and -mx=9 after -- failed the same way. When extracting, -oout after -- is treated as a file name filter, not an output folder.
A dash name is a switch without --: 7zz a -Arch2.7z real.txt stopped with "Unknown switch".
A path prefix also works without --: 7zz a dot.7z ./-x.txt stored -x.txt, and ./-Arch4.7z worked as an archive name.
Related pages