Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unzip into specific directory without recreate all the path with bash script

In my ios application, I need to unzip an archive that is placed into /var/mobile/Library/Preferences/xxx into, for example, /var/mobile/Library/Preferences/tmp.

My issue is that when I launch this:

unzip /var/mobile/Library/Preferences/xxx/archive.zip -d /var/mobile/Library/Preferences/tmp/

in the tmp folder, there is all the archive path: /var/mobile/Library/Preferences/tmp/var/mobile/Library/Preferences/xxx/archive/...

How could I do for only have /var/mobile/Library/Preferences/tmp/archive/... and not all the archive path into the target directory ?

Thanks in advance

like image 889
Synny Avatar asked Oct 06 '14 08:10

Synny


People also ask

How do I unzip a folder in Linux?

Unzipping a file from the command line is pretty straightforward using unzip <file> -d <folder> .

How unzip a zip file in Linux command line?

Command : unzip filename. zip -d unzipped_directory (or directory name)


1 Answers

Try the -j option to unzip which flattens the directory structure and writes all the files into the current directory.

like image 159
John Zwinck Avatar answered Oct 08 '22 19:10

John Zwinck