mem analyse
#! /bin/bash awk 'BEGIN{ total = 0; printf("SIZE\tRSS\tSHARED_CLEAN\tSHARED_DIRTY\tPRIVATE_CLEAN\tPRIVATE_DIRTY\n") }{ if(NF >3){ if($2 ~ /[r-][w-][x-][ps]/){ if($6 =="") name = $1; else name = $6; } } while(getline) { if(NF >3){ if($2 ~ /[r-][w-][x-][ps]/){ if($6 =="") name = $1; else name = $6; } } if($1 ~ /^Size/){ size = $2; total += $2; } if($1 ~ /Rss/){ rss = $2; } if($1 ~ /Shared_Clean/){ shared_clean = $2; } if($1 ~ /Shared_Dirty/){ shared_dirty = $2; } if($1 ~ /Private_Clean/){ private_clean = $2; } if($1 ~ /Private_Dirty/){ private_dirty = $2; } if($1 ~ /VmFlags/){ printf("%d\t%d\t%d\t%d\t%d\t%d\t%s\n",size,rss,shared_clean,shared_dirty,private_clean,private_dirty,name); size = 0; name = ""; rss = 0; shared_clean = 0; shared_dirty = 0; private_clean = 0; private_dirty = 0; continue; } } }END{ printf("====total: %d\n", total); }' $1