Question for you all....
![](https://seccdn.libravatar.org/avatar/ef78877acf7176d361adcf118a1f6648.jpg?s=120&d=mm&r=g)
....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.
![](https://seccdn.libravatar.org/avatar/cbc384749fe98165dc08fce731c4f993.jpg?s=120&d=mm&r=g)
Hi "cat first_file >> appended.file" ??? Jaska. Viestissä Maanantai 25. Maaliskuuta 2002 17:47, Michael Garabedian kirjoitti:
....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.
![](https://seccdn.libravatar.org/avatar/8039f7ad36befc22a77cb1b68fbe8568.jpg?s=120&d=mm&r=g)
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 This merges, sorts, and removes duplicates creating merged_passwd. Best Regards, Keith -- LPIC-2, MSCE, N+ you may say I'm a dreamer, but I'm not the only one Got spam? Get SPASTIC http://spastic.sourceforge.net
![](https://seccdn.libravatar.org/avatar/e7c8611332edb7a71061bb49c90ad6d6.jpg?s=120&d=mm&r=g)
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
![](https://seccdn.libravatar.org/avatar/cbdb2b4dc48489f0fdee30e8d42165c5.jpg?s=120&d=mm&r=g)
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
![](https://seccdn.libravatar.org/avatar/cbdb2b4dc48489f0fdee30e8d42165c5.jpg?s=120&d=mm&r=g)
On Monday 25 March 2002 18.27, Anders Johansson wrote:
cat passwd1 passwd2 | sort -u -n -t: +2 -3 > merged_passwd
oops, sorry, I missed the "-n". Guess the -3 isn't needed after all. The second part of my mail still stands, though :) //Anders
participants (5)
-
Anders Johansson
-
jaakko tamminen
-
Keith Winston
-
Michael Garabedian
-
Tara L Andrews