LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 07-25-2012, 12:13 PM   #1
Paradigm6790
LQ Newbie
 
Registered: Jul 2012
Posts: 2

Rep: Reputation: Disabled
Using zip to zip the contents of a directory to another?


Hello,

I am writing a tcl script that I use the zip command at the end to gather up the results of my scripts procedures into a zip file.

Let's say I have 2 paths:
/usr/whatever/tmp/startDir
/home/whatever/tmp/endDir

I am currently using:
Code:
exec zip -r /home/whatever/tmp/endDir /usr/whatever/tmp/startDir
The issue is that when I do this, while I DO get the contents of starDir, I also get the a folder structure in the zip file starting from /usr.

How do I get JUST the files in the startDir, and not the directories themselves?

Thanks!

Last edited by Paradigm6790; 07-25-2012 at 12:52 PM.
 
Old 07-25-2012, 12:33 PM   #2
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238

Rep: Reputation: Disabled
Code:
cd /usr/whatever/tmp/startDir
zip -r archive.zip *
Or you can put the archive to another directory (for instanse to your home):
Code:
cd /usr/whatever/tmp/startDir
zip -r ~/archive.zip *
If a directory contains hidden files, specify 'em like this:
Code:
zip -r archive.zip * .*
P. S. Wrap your code up with forum tags.

Last edited by Mr. Alex; 07-25-2012 at 12:45 PM.
 
Old 07-25-2012, 12:51 PM   #3
Paradigm6790
LQ Newbie
 
Registered: Jul 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
I get this error when trying to use the wildcard:

zip warning: name not matched: *

Edit: The error I was having was a TCL error. It ended up being more complicated than first anticipated in TCL, I had to iterate through a list. I ended up doing:
Code:
cd /usr/whatever/tmp/startDir
foreach f [glob *] {
	exec zip -r /home/whatever/tmp/endDir $f
}

Last edited by Paradigm6790; 07-25-2012 at 01:13 PM.
 
  


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
Linux zip program's -d -tt option deletes all files from zip archive Arun Gupta Linux - Software 4 04-27-2011 08:06 PM
zip -x for a directory - Subfolder contents not being excluded recursively? SirTristan Linux - Newbie 4 12-10-2010 04:52 AM
drivers for iomega zip 250 zip driveH tony044 Linux - Newbie 5 09-14-2010 07:19 AM
PHP ZIP MYSQL - open zip without writing it to disk benjalien Programming 2 01-15-2010 06:14 AM
Listing Zip file contents prasanta_sadhukhan Linux - General 1 10-20-2009 08:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:31 AM.

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
Open Source Consulting | Domain Registration