2

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

3
  • Try zip -r Klox.zip ~/Projects/Klox/* Apr 19, 2016 at 22:06
  • I've tried that it's not working, I don't know why, I red that /* should work but... Apr 19, 2016 at 22:10
  • 1
    cd ~/Projects/; zip -r ~/Klox.zip Klox/
    – Videonauth
    Apr 19, 2016 at 22:28

1 Answer 1

6

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 .