listusers2.sh 436 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. user=$(echo "$linea" | cut -d: -f1)
  12. uid=$(echo "$linea" | cut -d: -f3)
  13. shell=$(echo "$linea" | cut -d: -f 7)
  14. if [ $shell != "/usr/sbin/nologin" ]; then
  15. echo -e "user: $user($uid)\tgid: $(id -gn $uid)($(id -g $uid))"
  16. fi
  17. done < /etc/passwd