12-22-2014, 02:44 PM
Hi,
I have few lines from a command output and I need to join lines using regex and I want to capture the Output to a scalar variable for future use . Below is my Input Data :
-------------------------------------------- Starts from Below ----------------------
Smart Array P410i in Slot 0 (Embedded)
array A
physicaldrive 2C:1:1 (port 2C:box 1:bay 1, SAS, 1 TB, OK)
physicaldrive 2C:1:2 (port 2C:box 1:bay 2, SAS, 1 TB, OK)
array B
physicaldrive 2C:1:3 (port 2C:box 1:bay 3, SAS, 1 TB, OK)
physicaldrive 2C:1:4 (port 2C:box 1:bay 4, SAS, 1 TB, OK)
array C
physicaldrive 3C:1:5 (port 3C:box 1:bay 5, SAS, 1 TB, OK)
physicaldrive 3C:1:6 (port 3C:box 1:bay 6, SAS, 1 TB, OK)
array D
physicaldrive 3C:1:7 (port 3C:box 1:bay 7, SAS, 1 TB, OK)
physicaldrive 3C:1:8 (port 3C:box 1:bay 8, SAS, 1 TB, OK)
array E
physicaldrive 4C:2:1 (port 4C:box 2:bay 1, SAS, 1 TB, OK)
physicaldrive 4C:2:2 (port 4C:box 2:bay 2, SAS, 1 TB, OK)
array F
physicaldrive 4C:2:3 (port 4C:box 2:bay 3, SAS, 1 TB, OK)
physicaldrive 4C:2:4 (port 4C:box 2:bay 4, SAS, 1 TB, OK)
array G
physicaldrive 5C:2:5 (port 5C:box 2:bay 5, SAS, 1 TB, OK)
physicaldrive 5C:2:6 (port 5C:box 2:bay 6, SAS, 1 TB, OK)
array H
physicaldrive 5C:2:7 (port 5C:box 2:bay 7, SAS, 1 TB, OK)
physicaldrive 5C:2:8 (port 5C:box 2:bay 8, SAS, 1 TB, OK)
array I
physicaldrive 6C:3:1 (port 6C:box 3:bay 1, SAS, 1 TB, OK)
physicaldrive 6C:3:2 (port 6C:box 3:bay 2, SAS, 1 TB, OK)
array J
physicaldrive 6C:3:3 (port 6C:box 3:bay 3, SAS, 1 TB, OK)
physicaldrive 6C:3:4 (port 6C:box 3:bay 4, SAS, 1 TB, OK)
array K
physicaldrive 7C:3:5 (port 7C:box 3:bay 5, SAS, 1 TB, OK)
physicaldrive 7C:3:6 (port 7C:box 3:bay 6, SAS, 1 TB, OK)
unassigned
physicaldrive 7C:3:7 (port 7C:box 3:bay 7, SAS, 1 TB, OK)
physicaldrive 7C:3:8 (port 7C:box 3:bay 8, SAS, 1 TB, OK)
--------------ENDS ABOVE-----------------------------------------
O/P that I am looking for . I want to capture the O/P in to a variable and use the result for other operations .
array A physicaldrive 2C:1:1 port 2C:box 1:bay 1 SAS 1 TB OK physicaldrive 2C:1:2 port 2C:box 1:bay 2 SAS 1 TB OK
array B physicaldrive 2C:1:3 port 2C:box 1:bay 3 SAS 1 TB OK physicaldrive 2C:1:4 port 2C:box 1:bay 4 SAS 1 TB OK
array C physicaldrive 3C:1:5 port 3C:box 1:bay 5 SAS 1 TB OK physicaldrive 3C:1:6 port 3C:box 1:bay 6 SAS 1 TB OK
array D physicaldrive 3C:1:7 port 3C:box 1:bay 7 SAS 1 TB OK physicaldrive 3C:1:8 port 3C:box 1:bay 8 SAS 1 TB OK
array E physicaldrive 4C:2:1 port 4C:box 2:bay 1 SAS 1 TB OK physicaldrive 4C:2:2 port 4C:box 2:bay 2 SAS 1 TB OK
array F physicaldrive 4C:2:3 port 4C:box 2:bay 3 SAS 1 TB OK physicaldrive 4C:2:4 port 4C:box 2:bay 4 SAS 1 TB OK
array G physicaldrive 5C:2:5 port 5C:box 2:bay 5 SAS 1 TB OK physicaldrive 5C:2:6 port 5C:box 2:bay 6 SAS 1 TB OK
array H physicaldrive 5C:2:7 port 5C:box 2:bay 7 SAS 1 TB OK physicaldrive 5C:2:8 port 5C:box 2:bay 8 SAS 1 TB OK
array I physicaldrive 6C:3:1 port 6C:box 3:bay 1 SAS 1 TB OK physicaldrive 6C:3:2 port 6C:box 3:bay 2 SAS 1 TB OK
array J physicaldrive 6C:3:3 port 6C:box 3:bay 3 SAS 1 TB OK physicaldrive 6C:3:4 port 6C:box 3:bay 4 SAS 1 TB OK
array K physicaldrive 7C:3:5 port 7C:box 3:bay 5 SAS 1 TB OK physicaldrive 7C:3:6 port 7C:box 3:bay 6 SAS 1 TB OK
Thanks.
I have few lines from a command output and I need to join lines using regex and I want to capture the Output to a scalar variable for future use . Below is my Input Data :
-------------------------------------------- Starts from Below ----------------------
Smart Array P410i in Slot 0 (Embedded)
array A
physicaldrive 2C:1:1 (port 2C:box 1:bay 1, SAS, 1 TB, OK)
physicaldrive 2C:1:2 (port 2C:box 1:bay 2, SAS, 1 TB, OK)
array B
physicaldrive 2C:1:3 (port 2C:box 1:bay 3, SAS, 1 TB, OK)
physicaldrive 2C:1:4 (port 2C:box 1:bay 4, SAS, 1 TB, OK)
array C
physicaldrive 3C:1:5 (port 3C:box 1:bay 5, SAS, 1 TB, OK)
physicaldrive 3C:1:6 (port 3C:box 1:bay 6, SAS, 1 TB, OK)
array D
physicaldrive 3C:1:7 (port 3C:box 1:bay 7, SAS, 1 TB, OK)
physicaldrive 3C:1:8 (port 3C:box 1:bay 8, SAS, 1 TB, OK)
array E
physicaldrive 4C:2:1 (port 4C:box 2:bay 1, SAS, 1 TB, OK)
physicaldrive 4C:2:2 (port 4C:box 2:bay 2, SAS, 1 TB, OK)
array F
physicaldrive 4C:2:3 (port 4C:box 2:bay 3, SAS, 1 TB, OK)
physicaldrive 4C:2:4 (port 4C:box 2:bay 4, SAS, 1 TB, OK)
array G
physicaldrive 5C:2:5 (port 5C:box 2:bay 5, SAS, 1 TB, OK)
physicaldrive 5C:2:6 (port 5C:box 2:bay 6, SAS, 1 TB, OK)
array H
physicaldrive 5C:2:7 (port 5C:box 2:bay 7, SAS, 1 TB, OK)
physicaldrive 5C:2:8 (port 5C:box 2:bay 8, SAS, 1 TB, OK)
array I
physicaldrive 6C:3:1 (port 6C:box 3:bay 1, SAS, 1 TB, OK)
physicaldrive 6C:3:2 (port 6C:box 3:bay 2, SAS, 1 TB, OK)
array J
physicaldrive 6C:3:3 (port 6C:box 3:bay 3, SAS, 1 TB, OK)
physicaldrive 6C:3:4 (port 6C:box 3:bay 4, SAS, 1 TB, OK)
array K
physicaldrive 7C:3:5 (port 7C:box 3:bay 5, SAS, 1 TB, OK)
physicaldrive 7C:3:6 (port 7C:box 3:bay 6, SAS, 1 TB, OK)
unassigned
physicaldrive 7C:3:7 (port 7C:box 3:bay 7, SAS, 1 TB, OK)
physicaldrive 7C:3:8 (port 7C:box 3:bay 8, SAS, 1 TB, OK)
--------------ENDS ABOVE-----------------------------------------
O/P that I am looking for . I want to capture the O/P in to a variable and use the result for other operations .
array A physicaldrive 2C:1:1 port 2C:box 1:bay 1 SAS 1 TB OK physicaldrive 2C:1:2 port 2C:box 1:bay 2 SAS 1 TB OK
array B physicaldrive 2C:1:3 port 2C:box 1:bay 3 SAS 1 TB OK physicaldrive 2C:1:4 port 2C:box 1:bay 4 SAS 1 TB OK
array C physicaldrive 3C:1:5 port 3C:box 1:bay 5 SAS 1 TB OK physicaldrive 3C:1:6 port 3C:box 1:bay 6 SAS 1 TB OK
array D physicaldrive 3C:1:7 port 3C:box 1:bay 7 SAS 1 TB OK physicaldrive 3C:1:8 port 3C:box 1:bay 8 SAS 1 TB OK
array E physicaldrive 4C:2:1 port 4C:box 2:bay 1 SAS 1 TB OK physicaldrive 4C:2:2 port 4C:box 2:bay 2 SAS 1 TB OK
array F physicaldrive 4C:2:3 port 4C:box 2:bay 3 SAS 1 TB OK physicaldrive 4C:2:4 port 4C:box 2:bay 4 SAS 1 TB OK
array G physicaldrive 5C:2:5 port 5C:box 2:bay 5 SAS 1 TB OK physicaldrive 5C:2:6 port 5C:box 2:bay 6 SAS 1 TB OK
array H physicaldrive 5C:2:7 port 5C:box 2:bay 7 SAS 1 TB OK physicaldrive 5C:2:8 port 5C:box 2:bay 8 SAS 1 TB OK
array I physicaldrive 6C:3:1 port 6C:box 3:bay 1 SAS 1 TB OK physicaldrive 6C:3:2 port 6C:box 3:bay 2 SAS 1 TB OK
array J physicaldrive 6C:3:3 port 6C:box 3:bay 3 SAS 1 TB OK physicaldrive 6C:3:4 port 6C:box 3:bay 4 SAS 1 TB OK
array K physicaldrive 7C:3:5 port 7C:box 3:bay 5 SAS 1 TB OK physicaldrive 7C:3:6 port 7C:box 3:bay 6 SAS 1 TB OK
Thanks.