Zipping folder with absolute path without keeping tree of folders
I am attempting to use the zip -r
command to zip a folder which includes two files. I need to pass the absolute path of the folder with two files (/path/to/my/files/)
, which is causing all of the folders to be zipped with it, where as I only need the last folder (files/)
and its contents to be zipped, so that when the file is unzipped, there is only one folder and the two files within it. How can I modify the command to be able to pass the absolute paths in the arguments while keeping only the last folder?
Solution 1:
zip operates from the current working directory. If you have to return to the working directory you started from, that can work too.
Try:
cd /path/to/my
zip -r zipfile.zip files/
cd -