listusers.sh 427 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. #Guardar IFS anterior
  3. #SAVEIFS=$IFS
  4. #IFS=$(echo -en "\n\b")
  5. #for linea in $(cat /etc/passwd); do
  6. # echo "$linea"
  7. #done
  8. #Restauramos contexto
  9. #IFS=$SAVEIFS
  10. while read linea; do
  11. echo $linea | grep /usr/sbin/nologin >/dev/null
  12. if [ $? -ne 0 ]; then
  13. user=$(echo "$linea" | cut -d: -f1)
  14. uid=$(echo "$linea" | cut -d: -f3)
  15. echo -e "user: $user($uid)\tgid: $(id -gn $uid)($(id -g $uid))"
  16. fi
  17. done < /etc/passwd