Command to zip a directory using a specific directory as the root

I don’t think zip has a flag to do that. I think the only way is something like:

cd /var/www/oraviewer/rgn_download/download/ && \
   zip -r fcst_20100318_0319.zip fcst_20100318_0319

(The backslash is just for clarity, you can remove it and put everything on one line.)

Since PHP is executing the command in a subshell, it won’t change your current directory.

Leave a Comment