This question already has an answer here:

I have a directory called Klox with whats of files and images.

Klox is located in ~/Projects/Klox

When I use zip -r Klox.zip ~/Projects/Klox the archive is containing all the directories until reaching Klox. /home/vk/projects/Klox

I want the zip file to contain only the Klox folder. So people don't have to open home folder, then open vk folder then open projects and finally open Klox

marked as duplicate by WinEunuuchs2Unix, TheWanderer, Anwar, Kevin Bowen, Zanna Oct 22 '16 at 8:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Try zip -r Klox.zip ~/Projects/Klox/* – TheWanderer Apr 19 '16 at 22:06
  • I've tried that it's not working, I don't know why, I red that /* should work but... – Veliko Kosev Apr 19 '16 at 22:10
  • 1
    cd ~/Projects/; zip -r ~/Klox.zip Klox/ – Videonauth Apr 19 '16 at 22:28
up vote 6 down vote accepted

The zip utility stores paths relative to the current working directory, so you have to use cd or pushd/popd to go to ~/Projects first:

cd ~/Projects
zip -r Klox.zip Klox

or when you want to return to the original working directory afterwards:

pushd ~/Projects
zip -r Klox.zip Klox
popd

Not the answer you're looking for? Browse other questions tagged or ask your own question.