If we can perform this in Perl It would be fine as well.
I don’t know if this is even possible but this is what i want to be able to do. I am trying to get a memory percentage of memory being used (There may be better ways of doing this, please let me know)
I have this bash command
free -m | grep "Mem: " | awk '{print ($3/$2)*100}'
This will return a number, but what I want to do is set a variable to the output of the command.
So var1= Output of the above command
I believe this is what you are looking for:
Explanation:
$(...)syntax is called command substitution in shell.stdoutwithin that subshell.Aside:
The alternative syntax is with backticks:
but it’s not the preferred method due to readability and nesting issues.