Search code examples
macoscommand-lineunzip

How to extract only one file from a zip file on the mac command line?


I have a zip file with the following contents:

myzipfile.zip
  mydir1
    myfile1.txt
    myfile2.txt
  mydir2
    myfile3.txt
    myfile4.txt

I want to write a mac command line to only extract mydir2 - something like

unzip myzipfile.zip -magicparameter mydir2

My question is: How to extract only one file from a zip file on the mac command line?


Solution

  • unzip zip_file.zip path/to/file.txt

    This will extract the specified file.