[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Problems using zip

Posted on 2004-03-29
4
Medium Priority
?
218 Views
Last Modified: 2010-04-20
I'm trying to zip a directory into a zip file (and all sub dirs and files in the that dir)

I can get it to zip fine, but it stores the directory structure BEFORE the root location of the zip.

Example:
zip myfile.zip E:\www\mydir\ziphere

It zips from the E:, not from the ziphere, so when I extract the file I get the root folders... www then mydir then finally ziphere... that doens't work for my needs (moving zip file one machin to the next) how do I suporess the storing of this early dir structure *but maintain the strucutre beyond my root)?

thanks
0
Comment
Question by:happydog234
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:happydog234
ID: 10705813
To clarify, I'm not getting the content of those folders before the ziproot, but I'm getting the simplest dir strucuture,
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10706788
I have not used zip in a while, so I first have to check if there is a command line option to allow this. One option that will definitely work is to first cd to the "ziphere" directory and use something like this:

cd E:\www\mydir\ziphere
zip myfile.zip .

Or, if you want ziphere to be the first element:
cd e:\www\mydir
zip myfile.zip ziphere
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 2000 total points
ID: 10706911
Actually, make this
zip -r myfile.zip .
or
zip -r myfile.zip *

If your want all directories below ziphere, you need to specify the -r switch.

After reading the manpage, it does not look like you can ingore part of the path (you can however junk the directory information completey with the -j flag), so doing the cd is your only option.
0
 

Author Comment

by:happydog234
ID: 10707432
Many thanks- it worked!

[Hangs head in shame].  I can't believe I didn't think of changing the directory...
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question