how can i unzip a zip file with creating a new folder on the given path in linux

6,529

man unzip says:

 unzip [-Z] [-cflptTuvz[abjnoqsCDKLMUVWX$/:^]] file[.zip] [file(s) ...]  [-x xfile(s) ...] [-d exdir]

[-d exdir] An optional directory to which to extract files. By default, all files and subdirectories are recreated in the current directory; the -d option allows extraction in an arbitrary directory (always assuming one has permission to write to the directory). This option need not appear at the end of the command line; it is also accepted before the zipfile specification (with the normal options), immediately after the zipfile specification, or between the file(s) and the -x option. The option and directory may be concatenated without any white space between them, but note that this may cause normal shell behavior to be suppressed. In particular, -d ~ (tilde) is expanded by Unix C shells into the name of the user's home directory, but -d~ is treated as a literal subdirectory ~ of the current directory.

Alternatively, 7zip (7z command) supports the ZIP format and has a -o parameter for the same purpose

Share:
6,529

Related videos on Youtube

csx4
Author by

csx4

Updated on September 18, 2022

Comments

  • csx4
    csx4 over 1 year

    i have to unzip a file, i don't want to CD and then run mkdir newfolder then come again to the folder where i have the zip file and then run unzip file.zip /home/user/newfolder

    i want to simply run the command from the whichever directory i am it will create the folder for me or ask me that on location /home/user there's no newfolder directory exist do you want to create one (Y/n)? and chose it to y (doesn't matter if this operation need root access)

    i have checked unzip swtiches and google but in all the exmaples they make a directory then unzip the file in it

    i am using Debian Buster