当 AWS 自动扩展组执行启动脚本时,我在 ec2 Linux 实例中遇到了双括号和双美元符号的基本问题。
以下是错误:
-bash: syntax error near unexpected token `('
下面是代码
#!/bin/bash
total_ram=`free -g | awk 'FNR > 1 && FNR < 3 {print $2}'`
# if it's an odd value add one
if [ $$((total_ram%2)) -ne 0 ]; then total_ram=$$((total_ram+1)) ; fi
# divide by two
# half_ram=$((total_ram / 2))
sed "s,Xms.*,Xms$$((half_ram+0))g,g" -i /Users/rrapolu/ProjectDocs/shell/jvm.options
sed "s,Xmx.*,Xmx$$((half_ram+0))g,g" -i /Users/rrapolu/ProjectDocs/shell/jvm.options