Advertisement
angeldp

usuarios

Jun 12th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.57 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. clear
  4. if [ $# -eq 0 ]
  5.     then
  6.     echo "Debe ejecutar es script con parámetros"
  7.     exit
  8. fi
  9. if [ "$USER" != "root" ]
  10.     then
  11.     echo "Hay que sudar"
  12.     exit
  13. fi
  14. if [ "$1" = "-u" -o "$1" = "-U" ]
  15.     then
  16.     if [ -z "$2" ]
  17.         then
  18.         echo "Después de -u va un usuario"
  19.         exit
  20.     fi
  21.     VALIDAR=`more /etc/passwd | grep ^"${2}:"`
  22.     if [ -z "$VALIDAR" ]
  23.         then
  24.         echo "$2 no es un usuario del sistema"
  25.         exit
  26.     fi
  27.     DIRHOME=`echo $VALIDAR | cut -d: -f6`
  28.     PESO=`du -sh $DIRHOME | cut -f1`
  29.     echo "Usuario $2 encontrado"
  30.     echo "Dir home: $DIRHOME ocupa: $PESO"
  31.     exit
  32. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement