I am trying to get usernames from /etc/passwd
if UID equal/greater than 1000 using a for
loop. The below simple bash
script works but prints the username twice for some reason.
#!/bin/bash
for userid in `awk -F: '{print $3}' /etc/passwd`
do
if (("$userid" >= 1000)); then
echo "Valid User" :`cat /etc/passwd | grep $userid | awk -F: '{print $1,$3}'`
fi
done
awk -F : '$3 >= "1000" {print "Valid User " $1,$3}' /etc/passwd
?awk -F : '$3 >= 1000 {print "Valid User " $1,$3}' /etc/passwd