In a bash script I want to create an archive with 7z and exclude some directories. I created an exclude file that only contains one entry:excl_dir/My script:#!/bin/basharchiveName=my_archivebase=/path/to/base7z a -mx=9 -t7z -xr@exclude.lst ${archiveName}.7z ${base}/files/*The archive gets created but with the directory from the exclude file.Things I considered:The exclude file is UTF-8 encodedThe exclude file is in the same directory as my scriptI tried absolute and relative paths (i.e. /path/to/exclude.lst and ./exclude.lst)exclude file format: excl_dir/, excl_dir/*, newline after the entryIs the entry in the exclude file correct? When yes, what else could be wrong?Edit:When the entry in exclude.lst is just excl_dir, 7z actually excludes this folder. But also every file that has this string in it's name.
7z is not excluding directories from exclude file
shell script;7z
It looks like 7z can only exclude patterns and ignores trailing slashes. As a workaround, instead of excluding, pass it a list of the files you want to include:find . -not -path './excl_dir/*' -not -path './excl_dir' > /tmp/include.lst7z a -mx=9 -t7z -i@/tmp/include.lst foo.7z This seems like a bug in 7z. 