Sponsored Content
Top Forums Shell Programming and Scripting regex help to get unique hostnames Post 302352700 by xiamin on Sunday 13th of September 2009 01:34:35 AM
Old 09-13-2009
regex help to get unique hostnames

Hi

I have a file containing hostnames like this

Code:
(host=myhost.domain.com) or
(host=myhost)

i need to extarct the unique hostnames without the domain names from that file.
so my output should be myhost (without domain names)

But my regex skills are rusty

Code:
i tried grep "host" myfile|uniq

Code:
but this matches host=myhost.domain.com

instead of just everything after host=

any ideas on how do i construct my regex

Last edited by xiamin; 09-13-2009 at 03:31 AM..
 

10 More Discussions You Might Find Interesting

1. IP Networking

DHCP and Hostnames

I have a linksys DSL router. I run a mixed environment of Windows, Linux and Solaris. The routers dhcp tables show the windows machines hostnames and associated IP's ok but the unix bases mahines don't have associated hostnames in the DHCP tables. I can ping by IP but not my the machines... (5 Replies)
Discussion started by: mr16ga
5 Replies

2. Shell Programming and Scripting

get part of file with unique & non-unique string

I have an archive file that holds a batch of statements. I would like to be able to extract a certain statement based on the unique customer # (ie. 123456). The end for each statement is noted by "ENDSTM". I can find the line number for the beginning of the statement section with sed. ... (5 Replies)
Discussion started by: andrewsc
5 Replies

3. Shell Programming and Scripting

Change unique file names into new unique filenames

I have 84 files with the following names splitseqs.1, spliseqs.2 etc. and I want to change the .number to a unique filename. E.g. change splitseqs.1 into splitseqs.7114_1#24 and change spliseqs.2 into splitseqs.7067_2#4 So all the current file names are unique, so are the new file names.... (1 Reply)
Discussion started by: avonm
1 Replies

4. UNIX for Dummies Questions & Answers

Print unique lines without sort or unique

I would like to print unique lines without sort or unique. Unfortunately the server I am working on does not have sort or unique. I have not been able to contact the administrator of the server to ask him to add it for several weeks. (7 Replies)
Discussion started by: cokedude
7 Replies

5. Programming

Getting All VM Hostnames Using Pysphere

I need to obtain a list of all the hostname of all the VM's that reside on two ESXI servers using pysphere. I have attempted using the basic methods but an unable to get a hostname in my testing using: from pysphere import VIServer server = VIServer() ... (0 Replies)
Discussion started by: metallica1973
0 Replies

6. UNIX for Dummies Questions & Answers

Cyrillic Hostnames?

As the title suggests, I'm wondering if its possible to set a hostname to a name or word with Cyrillic letters (e.g. - Like the Russian alphabet). I tried installing the cyrillic-console package in Debian. I switched my desktop to Russian as well. However, when I try to set the hostname I get that... (2 Replies)
Discussion started by: Azrael
2 Replies

7. Shell Programming and Scripting

Ip address for multiple hostnames

i have a file which has 100 servers,i want a script which can output me ip address and hostname for that server. Thanks in advance!! input file abc.com output file should be abc.com 192.168.1..1 (1 Reply)
Discussion started by: Moon1234
1 Replies

8. Shell Programming and Scripting

Check for valid hostnames

Hello, I am trying to develop a script to check for valid hostnames. Below are the prerequisites for a valid hostname which I got from wiki : Hostnames are composed of series of labels concatenated with dots, as are all domain names. For example, "en.wikipedia.org" is a hostname. Each label... (8 Replies)
Discussion started by: rahul2662
8 Replies

9. Shell Programming and Scripting

Grouping hostnames for pdsh

Hi All, I have a list of hostnames in a text file and I would like to craft a bash script that would group them for use with pdsh. For example... I would like to group the following from a file: hostname1000 hostname1001 hostname1002 hostname1003 hostname1004 hostname2000... (4 Replies)
Discussion started by: joeg1484
4 Replies

10. Shell Programming and Scripting

Regex to identify unique words in a dictionary database

Hello, I have a dictionary which I am building for the Open Source Community. The data structure is as under HEADWORD=PARTOFSPEECH=ENGLISH MEANING as shown in the example below अ=m=Prefix signifying negation. अँहँ=ind=Interjection expressing disapprobation. अं=int=An interjection... (2 Replies)
Discussion started by: gimley
2 Replies
RESOLV.CONF(5)							File Formats Manual						    RESOLV.CONF(5)

NAME
resolv.conf - Domain Name System resolver configuration SYNOPSIS
/etc/resolv.conf DESCRIPTION
The /etc/resolv.conf is used to configure how the host will use the Domain Name System to resolve hostnames to IP addresses. It may con- tain these two lines: nameserver IP-address domain domain-name The nameserver entry tells the IP address of the host to use for DNS queries. If it is set to 127.0.0.1 (which is the default) then the local name daemon is used that may use the /etc/hosts database to translate host names. You normally only need a nameserver entry if the name server is at the other side of a router. The default nonamed name server can't look beyond the local network. The domain entry tells the default domain to use for unqualified hostnames. This entry is usually not given in which case the domain of the local host is used. The long version of this story can be found in resolver(5). FILES
/etc/resolv.conf DNS resolver configuration file. SEE ALSO
resolver(5), hosts(5), nonamed(8), boot(8). AUTHOR
Kees J. Bot (kjb@cs.vu.nl) RESOLV.CONF(5)
All times are GMT -4. The time now is 10:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy