Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 1 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
1  
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
add comment

Your Answer

 
discard

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.