#!/bin/bash
# http://www.lawebdelprogramador.com
# obtiene el usuario root y lo guarda en el archivo "listadoUsuarios"
cut -d: -f 1,6 /etc/passwd | grep ^'root:'> listadoUsuarios
# obtiene los usuarios con id igual o superior a 500 y los guarda en el
# archivo "listadoUsuarios"
cut -d: -f 1,3,6 /etc/passwd | awk -F: '{if($2>=500) print $1":"$3}' >> listadoUsuarios
# recorremos todos los usuarios
cat listadoUsuarios | while read usuario;do
username=`echo $usuario | cut -d: -f1`
path=`echo $usuario | cut -d: -f2`
# inicializamos las variables
discUsage=0
archivoPequeno=""
archivoGrande=""
# si el path del usuario existe
if [ -d "$path" ];then
# obtenemos el tamaño del mismo
discUsage=`du -sh $path | awk '{print $1}'`
# obtenemos el archivo mas pequeño
archivoPequeno=`find $path -type f -printf "%s %P\n" | sort -n | head -1`
# obtenemos el archivo mas grande
archivoGrande=`find $path -type f -printf "%s %P\n" | sort -n | tail -1`
else
discUsage="No existe directorio"
fi
# mostramos los resultados
echo $username
echo '\tpath:\t\t\t'$path
echo '\tutilizacion de disco:\t'$discUsage
echo '\tarchivo mas pequeno:\t'$archivoPequeno
echo '\tarchivo mas grande:\t'$archivoGrande
done
Comentarios sobre la versión: Versión 1 (0)
No hay comentarios