Save user names on .txt file witch username is listed in /etc/passwd file. Bash
Posted
by
user1448637
on Stack Overflow
See other posts from Stack Overflow
or by user1448637
Published on 2012-06-21T14:52:36Z
Indexed on
2012/06/21
15:16 UTC
Read the original article
Hit count: 190
well my goal is to make bash script to check if the username exist in /etc/passwd, if true i want to add it to the users.txt file.
i am not really good at UNIX programming so i hope somebody help me.
while(get to the end of /etc/passwd){
name=$(cat /etc/passwd | cut -d: -f1);
num1=$(cat /etc/passwd | cut -d: -f3);
num2=$(cat /etc/passwd | cut -d: -f4);
if(num1==num2)
/*i compare argv[0] with $name */
/* if true i=1 */
}
if(i==1)
save folowing string "argv[0]=agrv[1]"
else
"error message"
© Stack Overflow or respective owner