|
|
| Venkat Kandhari 2007-02-01, 9:56 pm |
| Hi-
I am very new to awk, I have the following output from the command from a
utility and I want to extract the first 2 Target IDs. Can you please let me
know how can we do this using awk?
Regards,
Venkat
------------------------------------------------------------------------
Controller information
------------------------------------------------------------------------
Controller type : SAS1064E
BIOS version : 6.08.04.00
Firmware version : 1.15.00.00
Channel description : 1 Serial Attached SCSI
Initiator ID : 63
Maximum physical devices : 62
Concurrent commands supported : 511
Slot : 0
Bus : 5
Device : 0
Function : 0
RAID Support : Yes
------------------------------------------------------------------------
IR Volume information
------------------------------------------------------------------------
IR volume 1
Volume ID : 0
Status of volume : Okay (OKY)
RAID level : 1
Size (in MB) : 76253
Physical hard disks (Target ID) : 1 4
------------------------------------------------------------------------
Physical device information
------------------------------------------------------------------------
Initiator at ID #63
Target on ID #1
Device is a Hard disk
Enclosure # : 1
Slot # : 1
Target ID : 1
State : Online (ONL)
Size (in MB)/(in sectors) : 152627/312581808
Manufacturer : ATA
Model Number : WDC WD1600JS-23M
Firmware Revision : 1C03
Serial No : WD-WMANM4183374
Drive Type : SATA
Target on ID #4
Device is a Hard disk
Enclosure # : 1
Slot # : 0
Target ID : 4
State : Online (ONL)
Size (in MB)/(in sectors) : 152627/312581808
Manufacturer : ATA
Model Number : WDC WD1600JS-23M
Firmware Revision : 1C03
Serial No : WD-WMANM5372274
Drive Type : SATA
------------------------------------------------------------------------
Enclosure information
------------------------------------------------------------------------
Enclosure# : 1
Logical ID : 5005076b:02405018
Numslots : 4
StartSlot : 0
Start TargetID : 0
Start Bus : 0
------------------------------------------------------------------------
| |
| Venkat Kandhari 2007-02-01, 9:56 pm |
| > Hi-
>
> I am very new to awk, I have the following output from a utility and I
> want to extract the first 2 Target IDs. Can you please let me know how can
> we do this using awk?
Just to clarify, i need the Tartget ID values, i.e. 1 and 4 (there could be
more than 2 or 1, 0 but i need the first 2) below "Physical device
information".
> Regards,
> Venkat
>
> ------------------------------------------------------------------------
> Controller information
> ------------------------------------------------------------------------
> Controller type : SAS1064E
> BIOS version : 6.08.04.00
> Firmware version : 1.15.00.00
> Channel description : 1 Serial Attached SCSI
> Initiator ID : 63
> Maximum physical devices : 62
> Concurrent commands supported : 511
> Slot : 0
> Bus : 5
> Device : 0
> Function : 0
> RAID Support : Yes
> ------------------------------------------------------------------------
> IR Volume information
> ------------------------------------------------------------------------
> IR volume 1
> Volume ID : 0
> Status of volume : Okay (OKY)
> RAID level : 1
> Size (in MB) : 76253
> Physical hard disks (Target ID) : 1 4
> ------------------------------------------------------------------------
> Physical device information
> ------------------------------------------------------------------------
> Initiator at ID #63
> Target on ID #1
> Device is a Hard disk
> Enclosure # : 1
> Slot # : 1
> Target ID : 1
> State : Online (ONL)
> Size (in MB)/(in sectors) : 152627/312581808
> Manufacturer : ATA
> Model Number : WDC WD1600JS-23M
> Firmware Revision : 1C03
> Serial No : WD-WMANM4183374
> Drive Type : SATA
> Target on ID #4
> Device is a Hard disk
> Enclosure # : 1
> Slot # : 0
> Target ID : 4
> State : Online (ONL)
> Size (in MB)/(in sectors) : 152627/312581808
> Manufacturer : ATA
> Model Number : WDC WD1600JS-23M
> Firmware Revision : 1C03
> Serial No : WD-WMANM5372274
> Drive Type : SATA
> ------------------------------------------------------------------------
> Enclosure information
> ------------------------------------------------------------------------
> Enclosure# : 1
> Logical ID : 5005076b:02405018
> Numslots : 4
> StartSlot : 0
> Start TargetID : 0
> Start Bus : 0
> ------------------------------------------------------------------------
>
>
| |
| Janis Papanagnou 2007-02-01, 9:56 pm |
| Venkat Kandhari wrote:
> Hi-
>
> I am very new to awk, I have the following output from the command from a
> utility and I want to extract the first 2 Target IDs. Can you please let me
> know how can we do this using awk?
awk '/^Target ID/{print $4; n++}n==2{exit}'
Janis
> Regards,
> Venkat
>
> ------------------------------------------------------------------------
> Controller information
> ------------------------------------------------------------------------
> Controller type : SAS1064E
> BIOS version : 6.08.04.00
> Firmware version : 1.15.00.00
> Channel description : 1 Serial Attached SCSI
> Initiator ID : 63
> Maximum physical devices : 62
> Concurrent commands supported : 511
> Slot : 0
> Bus : 5
> Device : 0
> Function : 0
> RAID Support : Yes
> ------------------------------------------------------------------------
> IR Volume information
> ------------------------------------------------------------------------
> IR volume 1
> Volume ID : 0
> Status of volume : Okay (OKY)
> RAID level : 1
> Size (in MB) : 76253
> Physical hard disks (Target ID) : 1 4
> ------------------------------------------------------------------------
> Physical device information
> ------------------------------------------------------------------------
> Initiator at ID #63
> Target on ID #1
> Device is a Hard disk
> Enclosure # : 1
> Slot # : 1
> Target ID : 1
> State : Online (ONL)
> Size (in MB)/(in sectors) : 152627/312581808
> Manufacturer : ATA
> Model Number : WDC WD1600JS-23M
> Firmware Revision : 1C03
> Serial No : WD-WMANM4183374
> Drive Type : SATA
> Target on ID #4
> Device is a Hard disk
> Enclosure # : 1
> Slot # : 0
> Target ID : 4
> State : Online (ONL)
> Size (in MB)/(in sectors) : 152627/312581808
> Manufacturer : ATA
> Model Number : WDC WD1600JS-23M
> Firmware Revision : 1C03
> Serial No : WD-WMANM5372274
> Drive Type : SATA
> ------------------------------------------------------------------------
> Enclosure information
> ------------------------------------------------------------------------
> Enclosure# : 1
> Logical ID : 5005076b:02405018
> Numslots : 4
> StartSlot : 0
> Start TargetID : 0
> Start Bus : 0
> ------------------------------------------------------------------------
>
>
| |
| Venkat Kandhari 2007-02-02, 3:56 am |
| "Janis Papanagnou" <Janis_Papanagnou@hotmail.com> wrote in message
news:epu262$5v0$1@online.de...
> Venkat Kandhari wrote:
>
> awk '/^Target ID/{print $4; n++}n==2{exit}'
Thanks. But this isn't fetching any output.
I modified it to awk '/^Target/{print $4; n++}n==2{exit}' and it outputs #1
and #4. How do we include "Target ID" so that it outputs 1 and 4.
Target on ID #1
Target ID :1
Target on ID #4
Target ID :4
[color=darkred]
>
>
> Janis
>
| |
|
| On 2 Feb., 05:35, "Venkat Kandhari" <khven...@cisco.com> wrote:
> "Janis Papanagnou" <Janis_Papanag...@hotmail.com> wrote in message
>
> news:epu262$5v0$1@online.de...
>
>
>
This outputs - with your data -, 1 and 4; what you asked for.
[color=darkred]
>
> Thanks. But this isn't fetching any output.
What do you mean by "fetching" output? Try to be precise.
> I modified it to awk '/^Target/{print $4; n++}n==2{exit}' and it outputs #1
> and #4. How do we include "Target ID" so that it outputs 1 and 4.
It already outputs 1 and 4.
If you also want the Lines with "Target on ID" in the output you
should have mentioned it in the first place; you asked for 1 and 4.
>
> Target on ID #1
> Target ID :1
> Target on ID #4
> Target ID :4
If you want to print the complete line and also the header lines
print the whole line $0 instead of field $4 and add /Target on ID/
to the program to get the header...
awk '/^Target ID/{print $0; n++}n==2{exit}/Target on ID/'
Janis
[color=darkred]
>
>
>
>
>
| |
| Venkat Kandhari 2007-02-02, 6:57 pm |
|
Thanks Janis.
One follow up question. As you can see there are several headings below like
"Controller information", "IR Volume information" & "Physical drive info" so
on.
Is it possible to extract this info individually.
Like some awk xyz command i should see only the following
------------------------------------------------------------------------
Controller information
------------------------------------------------------------------------
Controller type : SAS1064E
BIOS version : 6.08.04.00
Firmware version : 1.15.00.00
Channel description : 1 Serial Attached SCSI
Initiator ID : 63
Maximum physical devices : 62
Concurrent commands supported : 511
Slot : 0
Bus : 5
Device : 0
Function : 0
RAID Support : Yes
And some awk xyz command and should see only the following
------------------------------------------------------------------------
IR Volume information
------------------------------------------------------------------------
IR volume 1
Volume ID : 0
Status of volume : Okay (OKY)
RAID level : 1
Size (in MB) : 76253
Physical hard disks (Target ID) : 1 4
Regards,
Venkat
>
>
| |
| Janis Papanagnou 2007-02-02, 6:57 pm |
| Venkat Kandhari wrote:
> Thanks Janis.
> One follow up question. As you can see there are several headings below like
> "Controller information", "IR Volume information" & "Physical drive info" so
> on.
> Is it possible to extract this info individually.
Not sure whether you meant that, but try out the following command...
awk '/Controller information/{s=2}/^---/{s--}s>0'
....and replace the pattern for each type of data section. (You may also
pass the pattern as parameter, of course.)
For simplicity (to avoid look-ahead) it will skip the first dashed line.
Janis
>
> Like some awk xyz command i should see only the following
> ------------------------------------------------------------------------
> Controller information
> ------------------------------------------------------------------------
> Controller type : SAS1064E
> BIOS version : 6.08.04.00
> Firmware version : 1.15.00.00
> Channel description : 1 Serial Attached SCSI
> Initiator ID : 63
> Maximum physical devices : 62
> Concurrent commands supported : 511
> Slot : 0
> Bus : 5
> Device : 0
> Function : 0
> RAID Support : Yes
>
> And some awk xyz command and should see only the following
>
> ------------------------------------------------------------------------
> IR Volume information
> ------------------------------------------------------------------------
> IR volume 1
> Volume ID : 0
> Status of volume : Okay (OKY)
> RAID level : 1
> Size (in MB) : 76253
> Physical hard disks (Target ID) : 1 4
>
>
> Regards,
> Venkat
>
>
>
>
>
| |
| Venkat Kandhari 2007-02-02, 9:56 pm |
| "Janis Papanagnou" <Janis_Papanagnou@hotmail.com> wrote in message
news:eq0kia$peh$1@online.de...
> Venkat Kandhari wrote:
>
> Not sure whether you meant that, but try out the following command...
>
> awk '/Controller information/{s=2}/^---/{s--}s>0'
>
> ...and replace the pattern for each type of data section. (You may also
> pass the pattern as parameter, of course.)
>
> For simplicity (to avoid look-ahead) it will skip the first dashed line.
>
> Janis
Perfect!!! It works. Thank you so much.
Regards,
Venkat
[color=darkred]
>
|
|
|
|