On Monday 25 March 2002 18.21, Tara L Andrews wrote:
On Mon, Mar 25, 2002 at 11:19:24AM -0500, Keith Winston wrote:
On Mon, Mar 25, 2002 at 10:47:30AM -0500, Michael Garabedian wrote:
....I have two password files that I want to merge is there a command that will do it.
I have looked at diff, but I want to merge existing files to a new one.
Do you mean two /etc/passwd files? If so, you could do something like this:
cat passwd1 passwd2 | sort -u > merged_passwd
If you want to be fancy, you could use:
cat passwd1 passwd2 | sort -u -n -t: +2 > merged_passwd
which orders the entries by uid.
You want to make sure that you don't have two of the same userid in the merged file; sort won't catch that unless the entire line is identical.
-tara
cat passwd1 passwd2 | sort -u -n -t: +2 -3 > merged_passwd Otherwise you'll miss the cases where the same uid have different Full name or home dir or shell. Anyways, duplicate uid:s probably need more treatment than this. Presumably a lot of chown:ing and other modifications need to be done. //Anders