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 want to use the zip command to create a .ZIP of a folder but only include .txt files.

Subdirectory structure should be preserved!

share|improve this question
up vote 2 down vote accepted

If you're certain that none of the filenames will contain a newline then you can use find as explained in the zip(1) man page.

find some/dir -type f -name '*.txt' -print | zip ... -@ ...
share|improve this answer
I'm afraid it specifically says MacOS X does not support this :( – macek Nov 7 '11 at 5:20
It says "MacOS". OS X is Unix, not MacOS. – Ignacio Vazquez-Abrams Nov 7 '11 at 5:27

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.