No probs:
In awk the default record separator(RS) is "\n", so here I am setting the field separator(FS) to be the same so that each line is treated as the text I want to see. The default FS is white space.
If the line starts with an asterix(*) then do what is in the braces({})
Quote:
{var=$0;for(i=1;i<3;i++){getline;var=var"\n"$0}}
|
Set variable "var" equal to the whole line($0), which due to previous criteria will be a line full of asterixes.
The for loop then simply says to append the next two(2) lines to the variable with a newline(\n) in between.
So basically this gives you the header in "var", which for your file the first header will be:
Quote:
********************************
section 1
******************************
|
Starting with the line after the last row of asterixes in the header, find the first whole line that starts with match.
Again, if true, do the stuff in the braces({})
Found what we are looking for so print the header followed by a newline and the field we are in.
Because our FS (from above) is the newline then the number of fields (NF) per line is always 1
Let me know if I have lost you anywhere?