LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 11-03-2009, 06:03 AM   #1
Crazytje
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 'zip.zip'

Zipping that is pretty easy, 'zip -r zip.zip '/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 zip.zip zipme'
 
Old 11-03-2009, 06:43 AM   #2
kbp
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'

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

Rep: Reputation: 298Reputation: 298Reputation: 298
You could do this:

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

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


Reply


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 Filename.zip" , can it be done ??? htetnaing Linux - Newbie 2 08-17-2008 05:10 AM
how to zip blizunt7 *BSD 1 09-24-2006 03:37 PM
Zip gives error "-bash: /usr/bin/zip: Argument list too long" konathamsrinu Programming 3 07-06-2006 10:08 AM
.zip help Jmcatch742 Linux - General 1 11-16-2004 09:07 PM
create a self-extracting zip file with zip on solaris? samsolaris Solaris / OpenSolaris 3 10-15-2004 01:50 AM


All times are GMT -5. The time now is 06:25 PM.

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