Sponsored Content
Full Discussion: Hostsfile generator
Top Forums Shell Programming and Scripting Hostsfile generator Post 303040881 by RudiC on Friday 8th of November 2019 06:12:10 AM
Old 11-08-2019
man hosts:
Quote:
Fields of the entry are separated by any number of blanks and/or tab characters.


Guessing ENTRIES is your array, how far would this get you:
Code:
for IN in $(sort -u <<< $(echo "${!ENTRIES[*]}" | tr ',' '\n'))
  do    [ ! "${IN/[A-Z]}" = "$IN" ] && break
        printf "%s %s %s %s\n" "${ENTRIES[$IN",IP"]}" "${ENTRIES[$IN",HOST1"]}" "${ENTRIES[$IN",HOST2"]}" "${ENTRIES[$IN",COMMENT"]}"
  done; 
111.122.133.101 15533-rdp1 rdp1 
111.122.133.102 15533-rdp2 rdp2 # RDP-Terminal 2
111.122.133.20 unas15533 unas # UNAS
111.122.133.77 15533-wlan wlan # WLAN Access Point

 

9 More Discussions You Might Find Interesting

1. Cybersecurity

Password Generator

I need a great Password Generator program. I looked at a few of them, but none of them seemed to be what I wanted. So I have decided to write my own. (That's the cool thing about being a programmer....I always get what I want in software :) ) Do you have any password generators that you... (13 Replies)
Discussion started by: Perderabo
13 Replies

2. UNIX for Dummies Questions & Answers

date generator

Is there a command to generate the unix date that is in theshadow file?>? (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

3. Shell Programming and Scripting

How to compare result lpstat with hostsfile

Hi there all, I got a long list of printers installed and a longer list of printers in my hosts file. In the hosts file I got a even longer list of printers in the hosts file I got the IP adress of all printers next to the printer name. How can I get a script working to get the printers... (0 Replies)
Discussion started by: draco
0 Replies

4. Shell Programming and Scripting

Range generator

Dear All, I have a sorted file like 1 2 3 8 9 10 45 46 47 78 The output will be range like 1 3 8 10 45 47 78 78 (9 Replies)
Discussion started by: saifurshaon
9 Replies

5. Shell Programming and Scripting

Random Sentence Generator

Hi, I need to create a table with random sentences. I need lines that are upto 1000 characters in lenght. I need a random sentence generator that will create sentences and output it to a text file. The sentences should be of lenght varying from 1 to 1000. Does anyone know how this can be... (7 Replies)
Discussion started by: kaushys
7 Replies

6. What is on Your Mind?

Barcode Generator

QR Code Generator (0 Replies)
Discussion started by: Neo
0 Replies

7. Shell Programming and Scripting

time generator

Hi experts, I'd like to generate the table/file containing: number of milliseconds elapsed since midnight till midnight. It should contain 5 columns (hours minutes seconds milliseconds): Table will have theoretically 86 400 000 rows. My question is , is there somewhere the file or source... (7 Replies)
Discussion started by: hernand
7 Replies

8. Shell Programming and Scripting

Sequence generator

Thanks Guys This really helped (5 Replies)
Discussion started by: robert89
5 Replies

9. Shell Programming and Scripting

Generator script

Hello again unix.com people, I need your help again. I'm currently need a script that will generate ip ranges... lets say from 64.1.1.1 to 74.255.255.255 and the output should be like this: 64.1.1.2 64.1.1.3 ............. ............. 74.255.255.254 74.255.255.255 (line-by-line) ... (7 Replies)
Discussion started by: galford
7 Replies
HOSTS(5)						      BSD File Formats Manual							  HOSTS(5)

NAME
hosts -- host name data base DESCRIPTION
The hosts file contains information regarding the known hosts on the network. For each host a single line should be present with the follow- ing information: Internet address Official host name Aliases Items are separated by any number of blanks and/or tab characters. A ``#'' indicates the beginning of a comment; characters up to the end of the line are not interpreted by routines which search the file. Network addresses may either be specified for IP version 4 or version 6. IP version 4 addresses are specified in the conventional dotted address notation. IP version 6 addresses are specified using the colon-separated notation described in RFC1924. Host names may contain any printable character other than a field delimiter, newline, or comment character. The hosts file is read by mDNSResponder(8) and used to supply results for calls to getaddrinfo(3), getnameinfo(3), etc. in addition to results obtained from multicast and unicast DNS. FILES
/etc/hosts SEE ALSO
gethostent(3), getipnodebyname(3), getaddrinfo(3), getnameinfo(3) RFC1924: A Compact Representation of IPv6 Addresses. HISTORY
The hosts file format appeared in 4.2BSD. 4.2 Berkeley Distribution December 11, 1993 4.2 Berkeley Distribution
All times are GMT -4. The time now is 12:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy