- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Uniq entries needed...
Operating System - HP-UX
1752351
Members
5545
Online
108787
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-03-2011 09:24 PM
тАО06-03-2011 09:24 PM
Uniq entries needed...
Hi All,
I have the following command which returns the output like this -
wget URL|grep hostname|awk '{print $1,$3}'|/usr/bin/perl -nle 'm{"(.*?)".*?//(.*):(\d+)/} and print "$1 $2 $3"'|while read host port
do
echo check_env_$port
echo host
done
OUTPUT
Appname hostname port
Appname2 hostname port2 ...
Appnames are all unique , while hostname is not since I am grepping for single hostname(vip).
Some of the ports are not unique so I am getting the same port for 4-5 different appnames.
Within the same snippet of code I want to add a number to echo command so the its unique..
e.g. check_env_1_1234
check_env_2_1234
So for port 1234 it should increment the numbers.
If that's too hard then atleast get unique entries so that I don't get check_env_1234 not more than once which ever comes first and ignore the rest of the entries with the same port.
Thanks,
Allan.
I have the following command which returns the output like this -
wget URL|grep hostname|awk '{print $1,$3}'|/usr/bin/perl -nle 'm{"(.*?)".*?//(.*):(\d+)/} and print "$1 $2 $3"'|while read host port
do
echo check_env_$port
echo host
done
OUTPUT
Appname hostname port
Appname2 hostname port2 ...
Appnames are all unique , while hostname is not since I am grepping for single hostname(vip).
Some of the ports are not unique so I am getting the same port for 4-5 different appnames.
Within the same snippet of code I want to add a number to echo command so the its unique..
e.g. check_env_1_1234
check_env_2_1234
So for port 1234 it should increment the numbers.
If that's too hard then atleast get unique entries so that I don't get check_env_1234 not more than once which ever comes first and ignore the rest of the entries with the same port.
Thanks,
Allan.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2011 05:01 AM
тАО06-04-2011 05:01 AM
Re: Uniq entries needed...
Hi Allan:
One solution is to sort your output before your 'while read...' loop. Then, in the body of the loop, compare and increment a variable whose value becomes the count of the port instance.
Regards!
...JRF...
One solution is to sort your output before your 'while read...' loop. Then, in the body of the loop, compare and increment a variable whose value becomes the count of the port instance.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2011 05:19 AM
тАО06-04-2011 05:19 AM
Re: Uniq entries needed...
Hi (again) Allan:
...and I scanned right past this:
> If that's too hard then atleast get unique entries so that I don't get check_env_1234 not more than once which ever comes first and ignore the rest of the entries with the same port.
OK, so, use a 'sort -u' :
# wget ... | sort -u -k3,3 | while read ...
Regards!
...JRF...
...and I scanned right past this:
> If that's too hard then atleast get unique entries so that I don't get check_env_1234 not more than once which ever comes first and ignore the rest of the entries with the same port.
OK, so, use a 'sort -u' :
# wget ... | sort -u -k3,3 | while read ...
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP