- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: How to extract ID and device file
Operating System - Linux
1753835
Members
7585
Online
108806
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
Go to solution
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
тАО09-10-2007 10:12 AM
тАО09-10-2007 10:12 AM
Re: How to extract ID and device file
Did you try the awk construct I have posted? It does exactly what you're looking for viz., print the device ID followed by the device filename on the same line and it excludes the alternates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-10-2007 10:30 AM
тАО09-10-2007 10:30 AM
Re: How to extract ID and device file
Ah, you do want all and not just 'grep' for one. Try:
$ perl -nle '$dev=$1 if /^Logi.*\[(.*)\]/; if ($dev && /\s(c\d+t\S+)\s/) { print "$dev $1";$dev=""}
' devices.txt
$dev=$1 if /^Logi.*\[(.*)\]/; # remember stuff between box if line starts with 'Logi'
if ($dev && /\s(c\d+t\S+)\s/) # If we have a device and it looks like a 'ctd' on line
{ print "$dev $1";$dev=""} # print and clear device.
Hein.
$ perl -nle '$dev=$1 if /^Logi.*\[(.*)\]/; if ($dev && /\s(c\d+t\S+)\s/) { print "$dev $1";$dev=""}
' devices.txt
$dev=$1 if /^Logi.*\[(.*)\]/; # remember stuff between box if line starts with 'Logi'
if ($dev && /\s(c\d+t\S+)\s/) # If we have a device and it looks like a 'ctd' on line
{ print "$dev $1";$dev=""} # print and clear device.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-11-2007 02:51 AM
тАО09-11-2007 02:51 AM
Re: How to extract ID and device file
sandman,
Tried your method by simply copy and paste but didn't return anything.
awk '/device/{x=z[split(y[split($NF,y,"[")],z,"]")-1]};/active alive/{print x,$3;exit}' file1.out
Tried your method by simply copy and paste but didn't return anything.
awk '/device/{x=z[split(y[split($NF,y,"[")],z,"]")-1]};/active alive/{print x,$3;exit}' file1.out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-11-2007 03:05 AM
тАО09-11-2007 03:05 AM
Re: How to extract ID and device file
Thanks a bunch to James for simple solution - one liner!!!
- « Previous
-
- 1
- 2
- Next »
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