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

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


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:

I am currently using:
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?


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
cd /usr/whatever/tmp/startDir
zip -r *
Or you can put the archive to another directory (for instanse to your home):
cd /usr/whatever/tmp/startDir
zip -r ~/ *
If a directory contains hidden files, specify 'em like this:
zip -r * .*
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
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:
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.


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:30 PM.

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