0

Trying to run the following bash script. The output of the following ling fails:

mem = free | grep Mem | awk '{print $4/$2 * 100}'

With the error:

mem: command not found

JY2k
  • 2,879
  • 1
  • 31
  • 60

1 Answers1

2

Like this:

mem=$(free | grep Mem | awk '{print $4/$2 * 100}')

You can also use backticks:

mem=`free | grep Mem | awk '{print $4/$2 * 100}'`

But parentheses are preferred now. More: http://mywiki.wooledge.org/BashFAQ/082

BorisS
  • 686
  • 5
  • 9