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

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.

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 -@

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

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

Hint: That means it thinks ProjectZipFile is undefined :wink: Apparently you're using a different variable to define the filename than the one you specified in your OP.