in reply to Zip files while copying

I don't understand your problem. When you copy the file like cp srcdir/file destdir/file, could you just zip it instead like zip destdir/file.zip srcdir/file ? If not, could you please clarify your question, as in what are the statements that work but don't do what you want eg.?

Replies are listed 'Best First'.
Re^2: Zip files while copying
by aaron_baugher (Curate) on Nov 16, 2011 at 15:54 UTC

    One concern might be that if you give zip a pathname, it'll have that in the archive, and will want to unzip it there. So in your example, it'll want to unzip it as srcdir/file. That may or may not be a problem for him. On the other hand, if he copies it and then zips it, it'll be in the archive and unzip as destdir/file.

    Really, although you can use zip on single files, it's really designed for making archives of directory trees. So he might be better served with something like gzip, that only compresses and doesn't try to know the filenames/paths.

    Aaron B.
    My Woefully Neglected Blog, where I occasionally mention Perl.