Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-03-2009, 07:03 AM   #1
LQ Newbie
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
Need some help with using zip

I need some help using the zip command, I've read the man page, but did not find what I needed.

I want to zip the directory '/tmp/directory/zipme' to ''

Zipping that is pretty easy, 'zip -r '/tmp/directory/zipme'

the problem is that when unzipping it. Everything is in the directory structure '/tmp/directory/zipme/.....'

While I want zipme/... or even only the content of that dir.

So that when I unzip in /tmp/unzipped that the unzipped files are /tmp/unzipped/zipme/.... and not /tmp/unzipped/tmp/directory/zipme/...

I want to use this in a php script. So I can't 'cd' to that directory and use 'zip -r zipme'
Old 11-03-2009, 07:43 AM   #2
Senior Member
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
Using '-j' will junk any directory information and only store the files if that is what you want... zip doesn't have anything similar to tar's '--strip-components'

Old 11-03-2009, 09:17 AM   #3
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,295

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
You could do this:

PHP Code:
exec("cd /tmp/directory && zip -r zipme"); 
Old 11-03-2009, 09:44 AM   #4
LQ Newbie
Registered: Nov 2009
Posts: 2

Original Poster
Rep: Reputation: 0
thx, I'll try that.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
uncompress .zip with "tar -ixz" , can it be done ??? htetnaing Linux - Newbie 2 08-17-2008 06:10 AM
how to zip blizunt7 *BSD 1 09-24-2006 04:37 PM
Zip gives error "-bash: /usr/bin/zip: Argument list too long" konathamsrinu Programming 3 07-06-2006 11:08 AM
.zip help Jmcatch742 Linux - General 1 11-16-2004 10:07 PM
create a self-extracting zip file with zip on solaris? samsolaris Solaris / OpenSolaris 3 10-15-2004 02:50 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:32 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration