I am creating a script that will kill a task when my available RAM is below a certain value. For this I have this command that obtains the amount of RAM left. When I display it, I get a number "154372822" for example, but when I save it to a variable through $() it has that number with a: ": command not found" attached onto it.
Once I have this "var1" I wish to pass it into an if statement.
% Here is the issue line of code.
var1=$(awk -v low=$(grep low /proc/zoneinfo | awk '{k+=$2}END{print k}') \ '{a[$1]=$2} END{print a["MemFree:"]+a["Active(file):"]+a["Inactive(file):"]+a["SReclaimable:"]-(12*low);}' /proc/meminfo)
if [var1 -lt 1*1000*1000]; then
echo "Memory exceeded"
kill -9 $var2
break
else