Back (Current repo: scraps)

random scraps and notes that are useful to me
To clone this repository:
git clone https://git.viktor1993.net/scraps.git
Log | Download | Files | Refs

get_memory_usage.sh (336B)


#!/bin/bash
function get_memory_usage() {
    ps -eo size,pid,user,command --sort -size | awk 'BEGIN{print "Memory (Mb) What"}
    {
          hr=$1/1024;
          printf("%13.2f Mb ",hr);
    }
    {
        for ( x=4 ; x<=NF ; x++ ) {
            printf("%s \n",$x);
        }
    }' | awk '(NF==3){gsub(/^ +/, "", $0); print $0}'
}