Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following files:



Then I use the following command:

cd ~
zip /Dir1/file1.txt /Dir2/file2.txt

In the i can see two directories (dir1 and dir2) but want only these two files (file1.txt and file2.txt) were in the root of!

I thought the "-D" option is what I need, but it doesn't work :(

Please, give a clue!


share|improve this question

migrated from Jun 12 '11 at 14:11

This question came from our site for professional and enthusiast programmers.

shouldn't you be using Dir1/file1.txt Dir2/file2.txt instead – Fredrik Jun 10 '11 at 9:01
up vote 1 down vote accepted

I think the -j option is what you want:

zip -j ~/Dir1/file1.txt ~/Dir2/file2.txt

From the man page:

-j     Store just the name of a saved file (junk the path), 
       and do not store directory names. By default, zip 
       will store the full path (relative to the current path).
share|improve this answer
yep, thanks :) somehow I missed this flag.. – Dalamber Jun 10 '11 at 10:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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