2

I have an unzipping script on Linux.

It attempts to unzip with the command:

unzip file.zip 

This is obviously successful.

I now wish to exclude some files. The manual tells me of the -x option. I used that and it works also, but only for a single specified folder or file.

A method often used to exclude specific files from zipping programs is to pass in a .txt file with a single exclusion pattern per line.

Is this possible with Linux Unzip?

I have tried:

unzip file.zip -x excl_file.txt
unzip file.zip -x@excl_file.txt
unzip file.zip -x "excl_file.txt"

None of these seem to be the appropriate syntax.

Hennes
  • 64,768
  • 7
  • 111
  • 168
Tom
  • 23
  • 4

1 Answers1

2

You can't pass a file containing list of exclusions to unzip, you rather pass multiple arguments to -x. You could use command substitution to pass the list as an argument to the -x option for unzip:

unzip file.zip -x $(<excl_file.txt)
devnull
  • 3,305
  • 2
  • 16
  • 23