Sponsored Content
Top Forums Shell Programming and Scripting Check host file for duplicate entries Post 302160344 by reborg on Monday 21st of January 2008 05:27:12 PM
Old 01-21-2008
Code:
getent hosts | awk '{ ip[$1]++  
        for ( host=2; host <= NF; host++ ) { 
            hosts[$host] ++ 
        }
    }
    END { 
        for ( add in ip ) { 
            print add, ip[add], "times" 
        } 
        for ( h in hosts ) { 
            print h, hosts[h], "times" 
        }
    }'

Obviously you can add a check for only >1 occurrences if you like.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removal of Duplicate Entries from the file

I have a file which consists of 1000 entries. Out of 1000 entries i have 500 Duplicate Entires. I want to remove the first Duplicate Entry (i,e entire Line) in the File. The example of the File is shown below: 8244100010143276|MARISOL CARO||MORALES|HSD768|CARR 430 KM 1.7 ... (1 Reply)
Discussion started by: ravi_rn
1 Replies

2. Shell Programming and Scripting

duplicate entries /.rhosts file

Hi All, I have one problem related to /.rhosts file. According to my understanding, /.rhosts file is used for "rsh". What will happen if I have duplicate entries in this file? e.g> my .rhosts file looks like Code: wcars42g wcars89j wcars42g wcars42b wcars42b Will duplicate entries... (1 Reply)
Discussion started by: akash_mahakode
1 Replies

3. Shell Programming and Scripting

duplicate entries /.rhosts file

Hi, I forgot how to start a new thread. :( Can somebody please guide me? I have one problem related to /.rhosts file. According to my understanding, /.rhosts file is used for "rsh". What will happen if I have duplicate entries in this file? e.g> my .rhosts file looks like wcars42g... (2 Replies)
Discussion started by: akash_mahakode
2 Replies

4. Shell Programming and Scripting

to check the Linux upgrade in the host

Hi, how to check when was the linux upgrade has been done to this host. below command show the RHEL version. cat /etc/redhat-release Red Hat Enterprise Linux AS release 3 (Taroon Update 6) i want to know when it was upgraded.. is there any command available for that ? or anywhere we... (3 Replies)
Discussion started by: mail2sant
3 Replies

5. Shell Programming and Scripting

command to check whether the remote host is up or not

Hi, My script needs to check whether the remote host is up or not. If it is up i need to start few servers in that host or else just a notification should be sent that the remote host is down? Could someone help me out in this? Regards Arun (4 Replies)
Discussion started by: arunkumarmc
4 Replies

6. Shell Programming and Scripting

Counting duplicate entries in a file using awk

Hi, I have a very big (with around 1 million entries) txt file with IPv4 addresses in the standard format, i.e. a.b.c.d The file looks like 10.1.1.1 10.1.1.1 10.1.1.1 10.1.2.4 10.1.2.4 12.1.5.6 . . . . and so on.... There are duplicate/multiple entries for some IP... (3 Replies)
Discussion started by: sajal.bhatia
3 Replies

7. Shell Programming and Scripting

Request to check:remove entries with duplicate numbers in first row

Hi I have a file 1 xyz 456 1 xyz 456 1 xyz 456 2 abc 8459 3 gfd 657 4 ghf 658 4 ghf 658 I want the output 1 xyz 456 2 abc 8459 3 gfd 657 4 ghf 658 (3 Replies)
Discussion started by: manigrover
3 Replies

8. Shell Programming and Scripting

Check to identify duplicate values at first column in csv file

Hello experts, I have a requirement where I have to implement two checks on a csv file: 1. Check to see if the value in first column is duplicate, if any value is duplicate script should exit. 2. Check to verify if the value at second column is between "yes" or "no", if it is anything else... (4 Replies)
Discussion started by: avikaljain
4 Replies

9. Shell Programming and Scripting

How to check duplicate entries in file ? (Solaris-9)

Hi, There are duplicate entries in file, but uniq will not see because first field is different. How will I catch all lines, which are having duplicate IPs ? bash-2.05# cat db.file | grep 172.30.133.11 dsrq-ctrl1-prod A 172.30.133.11 e911q-db1-nxge0 A 172.30.133.11... (4 Replies)
Discussion started by: solaris_1977
4 Replies

10. UNIX for Beginners Questions & Answers

SFTP file check through a remote host

Hi all, posting my first time, hope not breaking posting rules with it, if yes, let me know. I'm trying to build a script to check a file in an sftp server through a remote server. The intention is to check the file in a sftp host, and if the file is found or not, it should send an email.... (4 Replies)
Discussion started by: MrShinyPants
4 Replies
GETENT(1)						    BSD General Commands Manual 						 GETENT(1)

NAME
getent -- get entries from administrative database SYNOPSIS
getent database [key ...] DESCRIPTION
The getent utility retrieves and displays entries from the administrative database specified by database, using the lookup order specified in nsswitch.conf(5). The display format for a given database is as per the ``traditional'' file format for that database. The database argument may be one of: Database Display format ethers address name group group:passwd:gid:[member[,member]...] hosts address name [alias ...] networks name network [alias ...] passwd user:passwd:uid:gid:gecos:home_dir:shell protocols name protocol [alias ...] rpc name number [alias ...] services name port/protocol [alias ...] shells /path/to/shell utmpx [time] type: properties If one or more key arguments are provided, they will be looked up in database using the appropriate function. For example, ``passwd'' sup- ports a numeric UID or user name; ``hosts'' supports an IPv4 address, IPv6 address, or host name; and ``services'' supports a service name, service name/protocol name, numeric port, or numeric port/protocol name. If no key is provided and database supports enumeration, all entries for database will be retrieved using the appropriate enumeration func- tion and printed. EXIT STATUS
The getent utility exits 0 on success, 1 if there was an error in the command syntax, 2 if one of the specified key names was not found in database, or 3 if there is no support for enumeration on database. SEE ALSO
getutxent(3), ethers(5), group(5), hosts(5), networks(5), nsswitch.conf(5), passwd(5), protocols(5), rpc(5), services(5), shells(5) HISTORY
A getent command appeared in NetBSD 3.0, and was imported into FreeBSD 7.0. It was based on the command of the same name in Solaris and Linux. BSD
August 24, 2005 BSD
All times are GMT -4. The time now is 06:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy