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(4)						     Kernel Interfaces Manual							  hosts(4)

NAME
hosts - The host name data base SYNOPSIS
/etc/hosts DESCRIPTION
The hosts file contains information regarding the known hosts on the network. For each host a single line should be present with the fol- lowing information: IP_address canonical_hostname aliases Items are separated by any number of blanks and/or tab characters. The # (number sign) indicates the beginning of a comment; characters up to the end of the line are not interpreted by routines which search the file. When using the name server named(8), this file provides a backup when the name server is not running. For the name server, it is suggested that only a few addresses be included in this file. These include address for the local interfaces that ifconfig(8) needs at boot time and a few machines on the local network. This file may be created from the official host data base maintained at the Network Information Control Center (NIC), though local changes may be required to bring it up to date regarding unofficial aliases and/or unknown hosts. As the data base maintained at NIC is incom- plete, use of the name server is recommend for sites on the DARPA Internet. Network addresses are specified in the conventional . notation using the inet_addr() routine from the Internet address manipulation library, inet_addr(3). Host names may contain any printable character other than a field delimiter, newline, or comment character. RELATED INFORMATION
Commands: ifconfig(8), named(8) Functions: gethostbyname(3) delim off hosts(4)
All times are GMT -4. The time now is 07:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy