Solved

Problems using zip

Posted on 2004-03-29
4
207 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
  • 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 500 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux Scripting 3 120
What language/protocol is the Angular Chat? 2 73
How to install Ubuntu 16 in DELL venue 8 pro 20 129
Securing Azure Oracle instance of Linux VM 4 56
How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now