greentea01
IS-IT--Management
Hi,
thought this is not going to be that hard but for me it obviously is.
I would like to parse some output and create a list from the lines following a hit of my search pattern.
The number of interesting lines which follow is variable but all start with two consecutive blanks.
What I want is a list of
pattern interestring1 interestring2
pattern2 interestring1 interestring2 interestring3
I tried with
and in desperation attempted
without success.
Thanks for help. Solution does not necessarily have to be awk btw.
thought this is not going to be that hard but for me it obviously is.
I would like to parse some output and create a list from the lines following a hit of my search pattern.
The number of interesting lines which follow is variable but all start with two consecutive blanks.
Code:
pattern: some other foo bar
interestring1: and other foo bar
interestring2: and other foo bar
pattern2: some other foo bar
interestring1: and other foo bar
interestring2: and other foo bar
interestring3: and other foo bar
What I want is a list of
pattern interestring1 interestring2
pattern2 interestring1 interestring2 interestring3
I tried with
Code:
for pattern in `cmd` ; do cmd2 | awk -F: '/'"$pattern"'/,!/^ / { print $1 }' | xargs ; done
and in desperation attempted
Code:
for pattern in `cmd` ; do cmd2 | awk -F: '/'"$pattern"'/,$1 !~ "^ " { print $1 }' | xargs ; done
Thanks for help. Solution does not necessarily have to be awk btw.