I would like to use tar
(on Windows) in a command line to extract files from an archive, that has a variable name, like *-archive.zip
, that I don't know beforehand. I haven't found a way to use a wildcard for the targeted archive name, is there an option to do that ?
I have tried things like tar -xf "*-archive.zip"
, but it searches for a file with the same exact name, not the pattern.
Thanks.
tar manual
in any www search engine should lead you to the GNU tar manual which contains the necessary information on how to use wildcard patterns by tar
itself and not by the shell interpreter. The Linux/Mac shell interpreters replace "*-archive.zip"
by a list of argument strings passed to tar
matching this wildcard pattern. The Windows Command Processor cmd.exe
does not do that. But tar.exe
can be instructed to search itself for ZIP files matching this wildcard pattern. Use 'tar --wildcards ...' (works at least with tar 1.33). Example:
╰─➤ $ tar --wildcards -tvf /home/johndoe/.cpan/sources/authors/id/T/TO/TODDR/XML-Parser-2.44.tar.gz '*enc'
-rw-r--r-- todd/staff 40706 2014-12-11 07:51 XML-Parser-2.44/Parser/Encodings/big5.enc
-rw-r--r-- todd/staff 45802 2014-12-11 07:51 XML-Parser-2.44/Parser/Encodings/euc-kr.enc
-rw-r--r-- todd/staff 1072 2014-12-11 07:51 XML-Parser-2.44/Parser/Encodings/ibm866.enc
...