Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 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
up vote 0 down vote accepted

I think you want to use the -x switch.

An example from the documentation:

7z a -tzip '*.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.