Kim Stacks
Kim Stacks

Reputation: 10812

extract specific folder in shell command using unzip

My backup.zip has the following structure.

OverallFolder

lots of files and subfolders inside

i used this unzip backup.zip -d ~/public_html/demo

so i end up with ~/public_html/demo/OverallFolder/my other files.

How do i extract so that i end up with all my files INSIDE OverallFolder GOING DIRECTLY into ~public_html/demo?

~/public_html/demo/my other files like this?

Upvotes: 0

Views: 2105

Answers (2)

Dennis Williamson
Dennis Williamson

Reputation: 360085

(cd ~public_html/demo; unzip $OLDPWD/backup.zip)

This, in a subshell, changes to your destination directory, unzips the file from your source directory, and when the subshell exits, leaves you back in your source directory.

That, or something similar, should work in most shells.

Upvotes: 0

ghostdog74
ghostdog74

Reputation: 342363

if you can't find any options to do that, this is the last resort

mv ~/public_html/demo/OverallFolder/* ~/public_html/demo/

Upvotes: 1

Related Questions