osx - Bash bc and echo commands -


i'm writing small geeklet geektool, alert me when sum of inactive , free ram on mac become slow. i'm not bash, have problem final output (getting blank). here code:

inmem=$(top -l 1|awk '/physmem/ {print $6}'|sed s/m//) | freemem=$(top -l 1|awk '/physmem/ {print $10}'|sed s/m//) | totalmem=$inmem+$freemem | bc | echo $totalmem 

also wonder if issue optimal or not. lot.

i wonder if simplify commands. can't test since i'm not on osx hope works.

read inmem freemem totalmem < <(top -l 1 | awk '/physmem/ { = $6; sub(/m/, "", i); f = $10; sub(/m/, "", f); printf("%d %d %d\n", i, f, + f); exit; }') echo "inmem: $inmem" echo "freemem: $freemem" echo "totalmem: $totalmem" 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -