Issue
i have a script that compare heapmemory
#!/bin/bash
$a=$(jcmd `jps -l | grep com.adobe.coldfusion.bootstrap.Bootstrap | cut -f1 -d ' '` GC.heap_info | awk 'NR==2 {print $5}')
$b=1000000K
if [[ $a -ge $b ]]
then
echo "The heapmemory used is greater."
else
echo "The heapmemory used is small."
fi
my question is when I am executing this script using ./testscriptforheap.sh
, although the output is correct but why I am getting this command not found in line number 2 and 3 I am not able to figure it out.
> ./testscriptforheap.sh: line 2: =1603644K: command not found
> ./testscriptforheap.sh: line 3: =1000000K: command not found
The heapmemory used is greater.
Solution
Assignments in bash (and also in sh) don't use the $
in front of them:
a=$(jcmd `jps -l | grep com.adobe.coldfusion.bootstrap.Bootstrap | cut -f1 -d ' '` GC.heap_info | awk 'NR==2 {print $5}')
b=1000000K
Answered By - Thomas Answer Checked By - Katrina (WPSolving Volunteer)