Sponsored Content
Full Discussion: Grouping hostnames for pdsh
Top Forums Shell Programming and Scripting Grouping hostnames for pdsh Post 302976798 by RudiC on Wednesday 6th of July 2016 10:39:34 AM
Old 07-06-2016
the shell might not be the fittest tool. Try awk:
Code:
awk '
                {HN = $1
                 sub (/[0-9]*$/, _, HN)
                 sub (/^[a-z]*/, _, $1)
                }
NR == 1         {printf "%s[%d-", HN, $1
                }
NR > 1 &&
$1 != LAST+1    {printf "%d,%d-", LAST, $1
                }
                {LAST = $1
                }
END             {printf "%d]\n", $1
                }
' file
hostname[1000-1004,2000-2002]

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

newbie question about hostnames

When I log into bash it will say my username @localhost I wondering how do I change localhost to another such as draco.I've the using the hostname command as root but it changes back to localhost after I reboot.I was wondering how would I hide my ISP hostname in linux.Because when I log into an IRC... (1 Reply)
Discussion started by: angelfly
1 Replies

2. 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

3. Shell Programming and Scripting

Scripting nslookup to resolve multiple hostnames

Hi Friends, I have a list of servers with their production names in a file. I want to know the best way eiter a command or a script that can do the following :- Append "-bkp" to each hostnames at the end And run nslookup and make sure I have valid backup IP add assigned to it. Any... (1 Reply)
Discussion started by: new2prog
1 Replies

4. Shell Programming and Scripting

regex help to get unique hostnames

Hi I have a file containing hostnames like this (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 i tried grep "host"... (4 Replies)
Discussion started by: xiamin
4 Replies

5. Shell Programming and Scripting

Compare file of hostnames with table in MySQL DB

Hi all, i have a list of files that contains some PC hostname, then i need to enumerate every hostname and check if there's a table with same name of the hosts in MySQL database XYZ. I need this because have to decide automatically if i have to make a create table or a insert into an existent... (2 Replies)
Discussion started by: maxlamax
2 Replies

6. UNIX for Dummies Questions & Answers

Is there a unix command to find ALL hostnames for an ip address?

I am trying to determine if there are several url/host names for an IP address. Is there a UNIX command to find ALL host names for an IP address? Thank you in advance. (3 Replies)
Discussion started by: rukasu
3 Replies

7. 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

8. 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

9. 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

10. 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
SDL_JoystickOpen(3)						 SDL API Reference					       SDL_JoystickOpen(3)

NAME
SDL_JoystickOpen- Opens a joystick for use. SYNOPSIS
#include "SDL.h" SDL_Joystick *SDL_JoystickOpen(int index); DESCRIPTION
Opens a joystick for use within SDL. The index refers to the N'th joystick in the system. A joystick must be opened before it game be used. RETURN VALUE
Returns a SDL_Joystick structure on success. NULL on failure. EXAMPLES
SDL_Joystick *joy; // Check for joystick if(SDL_NumJoysticks()>0){ // Open joystick joy=SDL_JoystickOpen(0); if(joy) { printf("Opened Joystick 0 "); printf("Name: %s ", SDL_JoystickName(0)); printf("Number of Axes: %d ", SDL_JoystickNumAxes(joy)); printf("Number of Buttons: %d ", SDL_JoystickNumButtons(joy)); printf("Number of Balls: %d ", SDL_JoystickNumBalls(joy)); } else printf("Couldn't open Joystick 0 "); // Close if opened if(SDL_JoystickOpened(0)) SDL_JoystickClose(joy); } SEE ALSO
SDL_JoystickClose SDL
Tue 11 Sep 2001, 23:00 SDL_JoystickOpen(3)
All times are GMT -4. The time now is 06:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy