cancel
Showing results for 
Search instead for 
Did you mean: 

To find diff ?

 
SOLVED
Go to solution
fizan
Super Advisor

To find diff ?

there are n no of users in two boxes actually i want to know who are existing in box1 & who are all in box2? i used diff command but it dosent give the gud o/p?

Thanks.
6 REPLIES
Sunny123_1
Esteemed Contributor

Re: To find diff ?

Hi

copy the box1 /etc/passwd file to /etc/passwd_box1.And then ftp that file to box 2 and then use diff command

diff /etc/passwd /etc/passwd_box1


Regards
Sunny
fizan
Super Advisor

Re: To find diff ?

thats wat i have done but after tat i grep one user in both the boxes they exist.
Sunny123_1
Esteemed Contributor
Solution

Re: To find diff ?

Hi

If you did that then you got the difference between these files and the users.


Regards
Sunny
Ganesan R
Honored Contributor

Re: To find diff ?

Hi Fizan,

If you want to compare the password file try this. First take the login names from server1 using this command.

#cat /etc/passwd |cut -d: -f1 > /tmp/logins

Copy the /tmp/logins file to server2 then run these commands.

# for i in `cat /tmp/logins`
> do
> grep $i /etc/passwd > /dev/null
> if [ $? -eq 0 ]
> then
> echo "$i account is exist on the server2"
> else
> echo "$i account does not exist on the server2"
> fi
> done

It will give you the output like which account exist on the server2 and which account does not exist.

Hope it helps you

Best wishes,

Ganesh.
Dennis Handly
Acclaimed Contributor

Re: To find diff ?

>I used diff command but it doesn't give the good o/p?

You can get the two files and sort them. Then use comm(1) to select which:
comm -23 pwd.1 pwd.2 # users on 1 and not 2
comm -13 pwd.1 pwd.2 # users on 2 and not 3
fizan
Super Advisor

Re: To find diff ?

thanks.