print value from offset row with bash
I have a command that provides system config info for each volume. I am trying to query a file containing the information for each volume, search out a volume group and respond with the associated volume. So basically
if the associated volume group = x then print volume name. Code:
Volume name: 2 |
Sounds like a great idea ... so what have you done to solve the problem? Also, is the data shown the answer or what we are to start with?
Please also place code / data in [code][/code] tags to make it more readable. |
That is a sample of the data that i am trying to parse. I will turn the solution into a variable "$volumename" for another function.
I have a basic understanding of awk so i can definitely find the line with associated volume group but i am at a loss on how to print the volume name from 8 rows up. This will find the line with volumegroup 1 and print it. But what i need is to print the volume name. Code:
volumegroup = 1 |
So why not store the volume name as you come across them and then when your expressions are correct you can print the saved value
|
I would be grateful if you would show me how to do that, or point me to an existing thread.
|
Same idea as what you have already done, simply add something like the following to the start:
Code:
$1 = "Volume name"{vname = $2} Code:
-F": *" |
All times are GMT -5. The time now is 08:45 PM. |