How to extract only a specific folder from a zipped archive to a given directory?
unzip /path/to/archive.zip "in/archive/folder/*" -d "/path/to/unzip/to"
Try:
unzip /path/to/archive.zip 'in/archive/folder/*' -d /path/to/unzip/to
The existing two answers are both correct, but it's a bit tricky to specify the target directory, that should be better clarified.
Let's say /target/root/
is the target dir upon the original unzip action, e.g.:
unzip -qq src.zip -d "/target/root/"
Then, we need to use the same /target/root/
as the target dir afterward even though we want to extract only a specific sub-directory, as the way unzip works:
unzip -qq src.zip "sub/dir/*" "/target/root/"
After all, the rule is actually simple, use the same target root directory for the -d
option.
BTW, the -qq
option is for unzip to be really quiet, feel free to remove it.