Question

I have two questions regarding unzip

  1. I am trying to extract the zip file everything after the first parent directory. i am trying this and its not working

    unzip -d /var/www/html/data/ file-gpl.zip */*

  2. The other questions in my old file someone has used unzip -W flag which i could not find in man page. what does it do

i tried this

[20:59][user1@core:/var/www/html/build]$ unzip -W -d test file.zip
UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

  -p  extract files to pipe, no messages     -l  list files (short format)
  -f  freshen existing files, create none    -t  test compressed archive data
  -u  update files, create if necessary      -z  display archive comment only
  -v  list verbosely/show version info       -T  timestamp archive to latest
  -x  exclude files that follow (in xlist)   -d  extract files into exdir
modifiers:
  -n  never overwrite existing files         -q  quiet mode (-qq => quieter)
  -o  overwrite files WITHOUT prompting      -a  auto-convert any text files
  -j  junk paths (do not make directories)   -aa treat ALL files as text
  -U  use escapes for all non-ASCII Unicode  -UU ignore any Unicode fields
  -C  match filenames case-insensitively     -L  make (some) names lowercase
  -X  restore UID/GID info                   -V  retain VMS version numbers
  -K  keep setuid/setgid/tacky permissions   -M  pipe through "more" pager
See "unzip -hh" or unzip.txt for more help.  Examples:
  unzip data1 -x joe   => extract all files except joe from zipfile data1.zip
  unzip -p foo | more  => send contents of foo.zip via pipe into program more
  unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer
Was it helpful?

Solution

1. unzip -d ./new/destination example.zip

2. I got the description for -W flag from my box is below

     -W     [only  when  WILD_STOP_AT_DIR compile-time option enabled] modifies the pattern matching routine so that both ‘?’ (single-char wildcard)
          and ‘*’ (multi-char wildcard) do not match the directory separator character ‘/’.  (The two-character sequence ‘‘**’’ acts as  a  multi-
          char wildcard that includes the directory separator in its matched characters.)  Examples:

           "*.c" matches "foo.c" but not "mydir/foo.c"
           "**.c" matches both "foo.c" and "mydir/foo.c"
           "*/*.c" matches "bar/foo.c" but not "baz/bar/foo.c"
           "??*/*" matches "ab/foo" and "abc/foo"
                   but not "a/foo" or "a/b/foo"

          This  modified  behaviour  is  equivalent  to the pattern matching style used by the shells of some of UnZip’s supported target OSs (one
          example is Acorn RISC OS).  This option may not be available on systems where the Zip archive’s internal directory  separator  character
          ‘/’  is  allowed  as regular character in native operating system filenames.  (Currently, UnZip uses the same pattern matching rules for
          both wildcard zipfile specifications and zip entry selection patterns in most ports.  For systems allowing ‘/’ as regular filename char-
          acter, the -W option would not work as expected on a wildcard zipfile specification.)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top