- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: file with duplication ignor anything where the...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2006 05:52 AM
тАО12-20-2006 05:52 AM
Re: file with duplication ignor anything where there is a duplicate.
# awk '{x[tolower($1)]++}END{for(i in x) if(x[i]==1) print i}' file
~cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2006 05:54 AM
тАО12-20-2006 05:54 AM
Re: file with duplication ignor anything where there is a duplicate.
Merry Christmas all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2006 06:06 AM
тАО12-20-2006 06:06 AM
Re: file with duplication ignor anything where there is a duplicate.
This can be accomplished by commands alone:
$ sort file | uniq -c | grep '1 ' | cut -c6-
Merry Christmas!
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2006 06:08 AM
тАО12-20-2006 06:08 AM
Re: file with duplication ignor anything where there is a duplicate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2006 06:29 AM
тАО12-20-2006 06:29 AM
Re: file with duplication ignor anything where there is a duplicate.
OK, silly me, I thought that your file contained only records with the listed fields.
Consider this file:
aanderson line-1
abergman line-2
abergman line-3
aboell line-4
aboell line-5
abone line-6
abridwell line-7
abridwell line-8
aburks line-9
achowdhury line-10
Now use:
# cat ./report
#!/usr/bin/perl
use strict;
use warnings;
my $file = shift;
my %names;
my @fields;
open (FH, "<", $file) or die "Can't open '$file': $!\n";
while (
@fields = split;
$names{$fields[0]}++;
}
seek( FH, 0, 0);
while (
@fields = split;
print if $names{$fields[0]} == 1;
}
1;
...thus:
# ./report file
aanderson line-1
abone line-6
aburks line-9
achowdhury line-10
...Perl counts the first field as zero whereas 'awk' would count it as one.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2006 06:32 AM
тАО12-20-2006 06:32 AM
Re: file with duplication ignor anything where there is a duplicate.
- « Previous
-
- 1
- 2
- Next »