Ich muss eine Variable innerhalb einer Bash for-Schleife setzen, die aus irgendeinem Grund nicht für mich funktioniert. Hier ist ein Auszug aus meinem Skript:Wie setze ich eine Variable innerhalb einer bash for loop?
function unlockBoxAll
{
appdir=$(grep -i "CutTheRope.app" /tmp/App_list.tmp)
for lvl in {0..24}
key="UNLOCKED_$box_$lvl"
plutil -key "$key" -value "1" "$appdir/../Library/Preferences/com.chillingo.cuttherope.plist" 2>&1> /dev/null
successCheck=$(plutil -key "$key" "$appdir/../Library/Preferences/com.chillingo.cuttherope.plist")
if [ "$successCheck" -eq "1" ]; then
echo "Success! "
else
echo "Failed: Key is $successCheck "
fi
done
}
Wie Sie sehen können, ich versuche, mit einer Variablen innerhalb der Schleife zu schreiben:
key="UNLOCKED_$box_$lvl"
Aber wenn ich das tue, bekomme ich diese:
/usr/bin/cutTheRope.sh: line 23: syntax error near unexpected token `key="UNLOCKED_$box_$lvl"'
/usr/bin/cutTheRope.sh: line 23: `key="UNLOCKED_$box_$lvl"'
Was mache ich nicht richtig? Gibt es einen anderen Weg, dies zu tun?
Bitte helfen Sie, danke.
Doh! Ich bin so dumm! Lol: P Vielen Dank! –