Extract multiple lines of data from a text file.
I need to take out like I have listed below and extract all the ALU Numbers out so I use those in another command. The length of the file changes so the line number is not exact. If I can at least extract out the lines with the ALU numbers then it is easy enough to remove the column I don't need. Any suggestions on what I can use to grab just those lines.
Here is an example of the type of output I am working with.
Storage Group Name: miux11_sg
Storage Group UID: C2:F3:D6:E8:F0:4A:DE:11:8A:FC:00:60:16:25:9F:FA
HBA UID SP Name SPPort
------- ------- ------
20:00:00:00:C9:43:46:3B:10:00:00:00:C9:43:46:3B SP B 6
20:00:00:00:C9:43:46:5F:10:00:00:00:C9:43:46:5F SP A 6
20:00:00:00:C9:43:46:5F:10:00:00:00:C9:43:46:5F SP B 7
20:00:00:00:C9:43:46:3B:10:00:00:00:C9:43:46:3B SP A 7
HLU Number ALU Number
Thanks for the help,
You gave us what you started with but not what you would like to end up with??
I would say awk, but hard to tell without know what you want.
What have you tried???
First, we need to define what is the unique attribute of the lines to be extracted. Looking at your sample, it could be:
1. Everything between "HLU Number ALU Number" and "Shareable"
2. Every line containing exactly 2 numbers and nothing else.
The second one is maybe the easiest (NOT TESTED):
http://www.grymoire.com/Unix/ look at both SED and AWK
Data that needs to be extracted.
In the output that I start with after the lines:
HLU Number ALU Number
There are sets of numbers and I need to extract just those numbers. Ideally I only want the numbers under the ALU Number column. I only want to extract numbers and just up to the line that starts with "Shareable:"
If I extract the numbers under HLU Number as well I know how to run that output through awk to just get ALU Numbers.
So in the above example I want the output of:
Once I get that data I plan on putting them in a loop.
Did you try my solution?
I tried the commands and did not get any output. The idea is what I am looking for because it is only lines with two numbers in it that I need to extract.
Thanks for pointing me in the write direction. The syntax I ended up using is this:
sed -n -r '/^[ ]+[0-9]+[ ]+[0-9]+$/ p'
I have just given you your first "thank you".
You posted a rational question
You posted follow-up
You took my knee-jerk suggestion, understood it, and then fixed it.
You posted your results.
You have no idea how rare this is----looking forward to seeing you here more.
|All times are GMT -5. The time now is 01:58 AM.|