trying to exclude all .svn folders in the zipped subfolders
zip -urq bebe.zip * -x .svn
doesn't work…
Best Answer
It seems like -x works with file names and not with directories. I don't fully understand how this option works.
But I do have a solution for your question :
find . -type d -name .svn -prune -o -print | zip -uq bebe.zip -@
The find command excludes all directories named .svn (-type d -name .svn -prune) and lists all other files and folders (-o -print). The list is passed to zip through a pipe (-@ option read list of files in standard input).
If you don't want to only include directories with regular files, you can use -o -type f -print instead.
I assume you really mean "symlink everything inside the folder"...
Conceptually, you want something like:
for each file in base folder not in exclude list
create symlink in target folder pointing back to base folder
done
bash logic to achieve this goes something like
#! /bin/bash
exclude=( "foo.conf" "bar.conf" )
for file in *; do
for (( index = 0; index < ${#exclude[@]}; index++ )); do
if [[ ${file} != ${exclude[${index}]} ]]; then
ln -s ${file} ${target}/${file}
fi
done
done
Assuming you don't know already, the Advanced Bash-Scripting Guide should give you enough to work out what globbing you want (perhaps find) and how to convert that to a function (perhaps a recursive one).
Best Answer
It seems like -x works with file names and not with directories. I don't fully understand how this option works.
But I do have a solution for your question :
The
find
command excludes all directories named .svn (-type d -name .svn -prune
) and lists all other files and folders (-o -print
). The list is passed to zip through a pipe (-@
option read list of files in standard input).If you don't want to only include directories with regular files, you can use
-o -type f -print
instead.