Explorar el Código

Clase Lunes 2017-10-30

Guzmán Castanedo Villalba hace 6 años
padre
commit
84bf369bd5
Se han modificado 1 ficheros con 20 adiciones y 0 borrados
  1. 20 0
      listusers.sh

+ 20 - 0
listusers.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+#Guardar IFS anterior
+#SAVEIFS=$IFS
+#IFS=$(echo -en "\n\b")
+#for linea in $(cat /etc/passwd); do
+#	echo "$linea"
+#done
+
+#Restauramos contexto
+#IFS=$SAVEIFS
+
+while read linea; do
+	echo $linea | grep /usr/sbin/nologin >/dev/null
+	if [ $? -ne 0 ]; then
+		uid=$(echo "$linea" | cut -d: -f1)
+		gid=$(echo "$linea" | cut -d: -f3)
+		echo -e "uid: $uid\tgid: $(id -gn $gid)"
+	fi
+done < /etc/passwd