0

i am experiencing a fundamental problem with double brakcets and double dollar signs in ec2 linux instances when the startup script is executed by AWS auto scaling group.

below is the error:

-bash: syntax error near unexpected token `('

below is the code

#!/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


New contributor
RamRapolu is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Use 1 dollar sign $ instead of 2 – oliv Aug 14 at 11:57
  • Thanks Oliv, yeah i tried with a single $ after i raised the case, it worked.Thanks once again for your quick response. – RamRapolu Aug 14 at 14:22

Your Answer

RamRapolu is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.