hervasiop12345

totalvsz

Aug 17th, 2011
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.45 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. #Description: Muestra los usuarios del sistema y la suma total de la memoria virtual consumida
  4. #
  5. #Author:jMa
  6. #
  7.  
  8. nombres=(`ps aux | tr -s " " | cut -d " " -f 1 | sed '1d' | sort -u`)
  9. suma=0
  10. echo -e "USER\t\tTOTALVSZ"
  11. for i in ${nombres[*]}
  12. do
  13.   ps aux | tr -s " " | cut -d " " -f 1,5 | grep $i | cut -d " " -f 2 > memv
  14.   while read line
  15.   do
  16.     let suma=$suma+$line
  17.   done < ./memv  
  18.   echo -e "$i\t\t$suma"
  19. done
  20. rm -f memv
Advertisement
Add Comment
Please, Sign In to add comment