Skip to content

Instantly share code, notes, and snippets.

@coffeemakr
Created October 1, 2014 08:39
Show Gist options
  • Select an option

  • Save coffeemakr/df6b21bc1fbbbbb36e1f to your computer and use it in GitHub Desktop.

Select an option

Save coffeemakr/df6b21bc1fbbbbb36e1f to your computer and use it in GitHub Desktop.

Revisions

  1. Cyril Müller created this gist Oct 1, 2014.
    14 changes: 14 additions & 0 deletions memory-info.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/bin/sh
    meminfo=`free -m | grep 'Mem:'`

    used=`echo $meminfo | cut -d" " -f3`
    total=`echo $meminfo | cut -d" " -f2`
    cached=`echo $meminfo | cut -d" " -f7`

    really_used=`expr $used - $cached`

    percent=$(bc -l <<EOF
    $really_used / $total * 100
    EOF
    )
    printf "<<M%.2f%%|C%s>>" $percent $cached