I'm trying to write a Bash Script that will create symlinks but exclude certain files.
I already looked up this thread but it doesn't help me:
https://serverfault.com/questions/165484/how-to-symlink-folders-and-exclude-certain-files
So this is the script I'm using at the moment:
#! /bin/bash
target=/home/csgo/game/output
cs=/home/csgo/game/csgo-deagle1
exclude=( "*.conf" "*.cfg" "*txt" "*.ini" "*.smx" "*.mp3" "*.sh" )
for file in ${cs}; do
for (( index = 0; index < ${#exclude[@]}; index++ )); do
if [[ ${file} != ${exclude[${index}]} ]]; then
ln -s ${file} ${target}
elif [[ ${file} == ${exclude[${index}]} ]]; then
cp ${file} ${target}
fi
done
done
The script should look in the exclude list and if the extension is excluded it should not make a symlink; it should copy the file into place instead.
At the moment the script creates a symlink of the directory but everything inside it is copied.