所以我需要将文件 /home/servers/template/craftbukkit.jar 复制到 /home/servers 内的每个文件夹中,例如。/home/servers/server1、/home/servers/server2 等
但我只想在 /home/servers/whateverserveritiscurrentlyon/mods 不存在的情况下这样做。这就是我想出的,想知道它是否会起作用:
echo " Script to copy a file to all server directories, only if mods does not exist in that directory"
for i in /home/servers/*/; do
if [ ! -d "$i/mods" ]; then
cp -f /home/servers/template/craftbukkit.jar "$i"
fi
done
echo " completed script ..."