Browse Source

Clase Lunes 2017-10-30

Guzmán Castanedo Villalba 3 years ago
parent
commit
b830e564dc
2 changed files with 6 additions and 6 deletions
  1. 3 3
      listusers.sh
  2. 3 3
      listusers2.sh

+ 3 - 3
listusers.sh

@@ -13,8 +13,8 @@
 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: -f4)
-		echo -e "uid: $uid\tgid: $(id -gn $uid)($gid)"
+		user=$(echo "$linea" | cut -d: -f1)
+		uid=$(echo "$linea" | cut -d: -f3)
+		echo -e "user: $user($uid)\tgid: $(id -gn $uid)($(id -g $uid))"
 	fi
 done < /etc/passwd

+ 3 - 3
listusers2.sh

@@ -11,10 +11,10 @@
 #IFS=$SAVEIFS
 
 while read linea; do
-	uid=$(echo "$linea" | cut -d: -f1)
-	gid=$(echo "$linea" | cut -d: -f4)
+	user=$(echo "$linea" | cut -d: -f1)
+	uid=$(echo "$linea" | cut -d: -f3)
 	shell=$(echo "$linea" | cut -d: -f 7)
 	if [ $shell != "/usr/sbin/nologin" ]; then
-		echo -e "uid: $uid\tgid: $(id -gn $uid)($gid)"
+		echo -e "user: $user($uid)\tgid: $(id -gn $uid)($(id -g $uid))"
 	fi
 done < /etc/passwd