我在工作中的PC上使用了此代码,我通过电子邮件将其发送给自己,当我回到家时,将其转移到了家用PC上。我唯一更新的是“ /home/jimmi/MobAction.csv”。这是正确的位置,我已经通过ls -l </ p>确认了
该脚本不再起作用。如果我尝试运行整个过程,我会得到
: integer expression expected
如果我分解并运行块,我会得到
bash: HitOutput=`rolldice -s 1d20+$HitMod`: ambiguous redirect
自
以来,这尤其令人困惑jimmi@DmScreen:~$ rolldice -s 1d20+$HitMod
Roll #1: (6) + 5 = 11
有效!
这是完整的脚本,如果有人可以告诉我发生了什么,我将非常感激
#!/bin/bash
#Requires "Mob" and "ActionType" to be declared when run, eg ./Dice.sh Orc M
#Requires software called RollDice to be installed. Rolldice is a dice roller eg "rolldice 1d6+2" rolls one six sided dice and adds two to the result
if [ $# -ne 2 ]
then echo "$0 requires two arguments only. A CamelCase monster name and 'M' or 'R' (Representing Melee or Ranged). Eg 'GoblinBoss M'"
exit
fi
Mob=${1}
ActionType=${2}
MobList=`awk -F ',' "/$Mob/"'{print $0}' "/home/jimmi/MobAction.csv" | awk -F ',' "/$ActionType/"'{print $1}'`
for Mob in $MobList
do
Ticker=0
Action=`awk -F ',' "/^$Mob,/"'{print $0}' "/home/jimmi/MobAction.csv" | awk -F ',' "/$ActionType/"'{print $2}'`
HitMod=`awk -F ',' "/^$Mob,/"'{print $0}' "/home/jimmi/MobAction.csv" | awk -F ',' "/$ActionType/"'{print $4}'`
Dice=`awk -F ',' "/^$Mob,/"'{print $0}' "/home/jimmi/MobAction.csv" | awk -F ',' "/$ActionType/"'{print $5}'`
DmgMod=`awk -F ',' "/^$Mob,/"'{print $0}' "/home/jimmi/MobAction.csv" | awk -F ',' "/$ActionType/"'{print $6}'`
DmgType=`awk -F ',' "/^$Mob,/"'{print $0}' "/home/jimmi/MobAction.csv" | awk -F ',' "/$ActionType/"'{print $7}'`
Attacks=`awk -F ',' "/^$Mob,/"'{print $0}' "/home/jimmi/MobAction.csv" | awk -F ',' "/$ActionType/"'{print $8}'`
SedMob=`echo $Mob | sed -r 's/([a-z0-9])([A-Z])/\1 \L\2/g' | sed -e 's/.*/\L&/' -e 's/[a-z]*/\u&/g'`
while [ $Ticker -lt $Attacks ]
do
MobActionOutput="$SedMob attacks with $Action (`expr $Ticker + 1` of $Attacks)"
HitOutput=`rolldice -s 1d20+$HitMod`
DmgOutput=`rolldice $Dice+$DmgMod`
echo ""
echo "+---------------------------------------------+"
echo $MobActionOutput
echo "Rolls" "${HitOutput:9}" "to hit"
echo "Potentially dealing" $DmgOutput $DmgType "damage"
echo "+---------------------------------------------+"
echo ""
Ticker=`expr $Ticker + 1`
done
done
exit