Restricting zip to current directory only


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Restricting zip to current directory only
# 1  
Old 09-15-2009
Restricting zip to current directory only

I am using the following command in a C shell script:

find . -name "*.*" -print | zip $ProjectZipFile -@

to zip files in a Unix (Sun and/or Linux) directory for archiving purposes. This command works fine, the only problem being that if sub-directories are present, they are included in the zip as well. How do I need to change my command so that only the files in the current directory, and no sub-directories if present, are included in the zip file?

Thanks,
Paul Hudgens
Denver
# 2  
Old 09-15-2009
Code:
find . -maxdepth 1 -type f | zip $ProjectZipFile -@

"*.*" is a DOS thing, UNIX doesn't use file extensions or do that kind of wildcard match, and you don't need to specify any names at all for find to find everything.
# 3  
Old 09-15-2009
Corona 688 has a good answer if your find command supports the maxdepth option. If it doesn't, I think Perderabo posted something in the past that also might help you, along the lines of:

find . \( ! -name . -prune \) -type f | zip $ProjectZipFile -@
# 4  
Old 10-07-2009
Sorry about my delay in replying - I'm finally getting time to get back to this. I have tried both procedures suggested, but neither worked on either UNIX or LINUX. I was getting "ProjectZipFile: Undefined variable" messages. I have not checked Perderabo, but will try tomorrow.

Thanks, Paul Hudgens
# 5  
Old 10-13-2009
Restricting zip to current directory only

Sorry about my delay in replying - I'm finally getting time to get back to this. I have tried both procedures suggested, but neither worked on either UNIX or LINUX. I was getting "ProjectZipFile: Undefined variable" messages. I checked Perderabo and found the -prune command which I successfully used in the following command:

find * -prune -type f | zip $Gf66ZipFile -@

This successfully zips only the files in the current directory, on both Unix and Linux, regardless of whether sub-directories are present or not.

Thanks,
Paul Hudgens
# 6  
Old 10-13-2009
Quote:
Originally Posted by phudgens
Sorry about my delay in replying - I'm finally getting time to get back to this. I have tried both procedures suggested, but neither worked on either UNIX or LINUX. I was getting "ProjectZipFile: Undefined variable" messages.
Hint: That means it thinks ProjectZipFile is undefined Smilie Apparently you're using a different variable to define the filename than the one you specified in your OP.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Restricting directory access in Apache server

Hi all, I have a web site that I'm serving on an Apache server, and it has a number of different folders, but I only want the user to be able to access certain ones -- the majority of them I don't want the user to access. I tried modifying my /etc/apache2/conf.d/security file to do this, but I... (1 Reply)
Discussion started by: Zel2008
1 Replies

2. UNIX for Dummies Questions & Answers

Restricting a Find search to the current directory only

Hi All, I am trying to delete file (with a mtime older than 2 days) from the current directory ONLY using: find . -daystart -maxdepth 1 -mtime 2 -exec rm {} \; but this doesn't seem to work it is still find files in subdirectories which I don't want to delete. Please can anyone offer... (2 Replies)
Discussion started by: daveu7
2 Replies

3. UNIX for Dummies Questions & Answers

Restricting a user to their home directory and below

I found this old closed thread: I can do these things, but how to I change someone's profile - where do I find the profile? I'm running Centos 5.6 ~~~~~~~~~ providing you have the password shell set to ksh, you can put this in his .profile: cd /opt/load alias -x cd=: (6 Replies)
Discussion started by: jjj0923
6 Replies

4. UNIX for Dummies Questions & Answers

Zip recursive content of folder when (not current directory=

Hi, Is there a way to zip the content (recursively) of a folder other then the current directory, and keep the directory structure intact? Example: /var/tmp/myfolder ----------------- file1 ----------------- file2 ----------------- folder1 ------------------------ file3 Now I want... (3 Replies)
Discussion started by: jimih
3 Replies

5. UNIX for Dummies Questions & Answers

Problem with Restricting Directory in Apache

Hello, I want to restrict access to our Subversion repositories to only our internal network. I have a virtual host directive setup in Apache for the IP and port 443. When I put the following: <Directory "/var/www/svn/"> Order allow,deny AllowOverride None Allow from 10.5.10.0/24 Allow... (1 Reply)
Discussion started by: mojoman
1 Replies

6. UNIX for Dummies Questions & Answers

Problem with Restricting Directory in Apache

Hello, I want to restrict access to our Subversion repositories to only our internal network. I have a virtual host directive setup in Apache for the IP and port 443. When I put the following: <VirtualHost 205.147.86.33:443> <Directory "/var/www/svn/"> Order deny,allow AllowOverride... (0 Replies)
Discussion started by: mojoman
0 Replies

7. Solaris

Restricting SFTP user to a defined directory and home directory

Hi, I've created solaris user which has both FTP and SFTP Access. Using the "ftpaccess" configuration file options "guest-root" and "restricted-uid", i can restrict the user to a specific directory. But I'm unable to restrict the user when the user is logged in using SFTP. The aim is to... (1 Reply)
Discussion started by: sftpuser
1 Replies

8. Solaris

Restricting FTP access for a particular directory

Dear All, I have created a user called "x" who is allowed only to FTP and it is working fine. Here my problem is, I want to give access to a particular directory say for eg:- /dump/test directory. I don't find any option in the useradd command to restrict access to this particular directory only... (1 Reply)
Discussion started by: Vijayakumarpc
1 Replies

9. Shell Programming and Scripting

Finding files in current directory when 100,000's files in current directory

Hi All I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age. I have experimented with the find command in unix but it also searches all sub directories. I have... (2 Replies)
Discussion started by: kewong007
2 Replies

10. UNIX for Dummies Questions & Answers

Question about Restricting Search path of FIND to current directory

Hi, By default FIND command searches for matching files in all the subdirectories within the specified path. Is there a way to restrict FIND command's search path to only the specified directory and NOT TO scan its subdirectories. Any help would be more than appreciated. Thanks and Regards (2 Replies)
Discussion started by: super_duper_guy
2 Replies
Login or Register to Ask a Question