It may be obvious, but I couldn't find the answer even if I looked it up in the feeling, so I'll write it down for the purpose of reminders.
When you want to decompress only a specific file with the unzip command
If you have a zip file like the one below
hoge.zip
$ zipinfo -1 hoge.zip
aaa/bbb/ccc.txt
ddd/eee/fff.jpg
ggg/hhh/iii.log
This can be achieved with unzip {zip to be decompressed} {file path you want to extract}.
$ unzip hoge.zip aaa/bbb/ccc.txt
But if the directory delimiter in the zip file was a backslash
hoge_bs.zip
$ zipinfo -1 hoge_bs.zip
aaa\bbb\ccc.txt
ddd\eee\fff.jpg
ggg\hhh\iii.log
If you enter the command in the same way, an error will occur.
$ unzip hoge_bs.zip aaa\bbb\ccc.txt
Archive: hoge_bs.zip
caution: filename not matched: aaabbbccc.txt
Should I enclose it in single quotes? I think this is also useless
$ unzip hoge_bs.zip 'aaa\bbb\ccc.txt'
Archive: hoge_bs.zip
caution: filename not matched: aaa\bbb\ccc.txt
Is the path actually converted to a slash when expanded? I tried it, but this is also useless
$ unzip hoge_bs.zip 'aaa/bbb/ccc.txt'
Archive: hoge_bs.zip
caution: filename not matched: aaa/bbb/ccc.txt
It worked well when I gave it two backslashes
$ unzip hoge_bs.zip 'aaa\\bbb\\ccc.txt'
Archive: hoge_bs.zip
warning: hoge_bs.zip appears to use backslashes as path separators
inflating: aaa/bbb/ccc.txt
When I put it together like this, I'm starting to regret that this is common sense ...
Recommended Posts