Re: remove line if field one is duplicate
- From: pangj@xxxxxxxxxxxxx (Jeff Pang)
- Date: Wed, 28 Feb 2007 18:08:49 +0800 (GMT+08:00)
-----Original Message-----
From: "Keenan, Greg John (Greg)** CTR **" <gjkeenan@xxxxxxxxxxxxxxxxxx>
Sent: Feb 28, 2007 12:39 PM
To: beginners@xxxxxxxx
Subject: remove line if field one is duplicate
Hi,
I have to combine several Unix password files and remove any duplicate
accounts - putting this into LDAP.
I have the following code that will remove any duplicate whole lines but
I need to remove lines only if the first field of the password file is a
duplicate.
Hello,
Just give a simple test and I think this may work:
$ perl -Mstrict -e '
my %hash; open HD,"/etc/passwd" or die $!;
my @uniq_users = map { $_->[1] } grep { ++$hash{$_->[0]} < 2 } map { [(split/:/)[0],$_] } <HD>;
print @uniq_users '
--
Jeff Pang
EMAIL: pangj<at>earthlink.net AIM: jeffpang
.
- Prev by Date: Re: Scan disk for files with certain owner
- Next by Date: Re: Scan disk for files with certain owner
- Previous by thread: Re: remove line if field one is duplicate
- Next by thread: Scan disk for files with certain owner
- Index(es):
Relevant Pages
|
|