Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to use the 7z command to compress some of files, but I want it to exclude some of the files. I tried the -ai, -ax, and -i switches, but no one seems to work. I need the compressed archive keep the directories, so I cannot use the find command to list the files I need and pass them to xargs.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I think you want to use the -x switch.

An example from the documentation:

7z a -tzip archive.zip '*.txt' '-x!temp.*'

would archive all .txt files but exclude temp.* files.

Note that on Linux, file specifications should be quoted so 7zip can expand them instead of letting the shell do it.

share|improve this answer
Thanks. I tried, but did not work...In the end, I have install the 'zip' tool to get this job done. –  davidshen84 Mar 5 '11 at 9:24

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.