Artificial intelligent assistant

Bash: kill process in function of the memory used I made this script to close a process, but I can't compare the `awk` result (`var1`) with an Integer: `var1 -gt 5000`. My script: #!/bin/bash var1= free -m |awk 'NR == 2'| awk '{print $3}' var2= ps aux | grep '/opt/skype/skype' | grep -v grep | awk '{print $2}' while true; do if [ $var1 -gt 5000 ]; then echo "La memoria se ha excedido cerrando porcesos" kill -9 $var2 break else echo "La memoria aun es estable $var1" fi done Could it be a casting problem in bash?

You can cast variables in bash and ksh (use `declare -i var` or `typeset -i var` for interger), but I don't think that is your problem.

The following will set `var1` to nothing while then running the command as normal.


var1= free -m |awk 'NR == 2'| awk '{print $3}'


If you want the output of free and awk to be set to var1 then the above should read:


var1=$( free -m |awk 'NR == 2'| awk '{print $3}' )

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy a2fba47e4dd428cca6b400dd241a9e35