Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Aug 2010 17:16:20 +0200
From:      "Dr. Andreas Haakh" <andreas@Haakh.de>
To:        "Jack L. Stone" <jacks@sage-american.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Extracting a variable listing
Message-ID:  <4C6BF944.5060302@Haakh.de>
In-Reply-To: <4C6BF8EA.3020406@Haakh.de>
References:  <3.0.1.32.20100818084231.00ecef30@sage-american.com> <4C6BF8EA.3020406@Haakh.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Dr. A. Haakh schrieb:
> Jack L. Stone schrieb:
>> Sorry to return to the trough again for script help, but find excellent
>> answers here when all else fails, and I am not very good at it.
>>
>> Trying to develop a script (non-bash) that will extract a variable 
>> list of
>> content on a daily basis so I can add it to a master list. Once I have
>> this, I can do the rest of the scripting needed.
>>
>> Here's an example of the need.
>>
>> The content I need will always fall beneath a row of pound signs, and 
>> there
>> is content above that row I don't want, like this:
>>
>> bunch of rows I don't need here
>> ############################### <--- the top of stuff needed
>> row1
>> row2
>> row3
>> row4
>> etc, etc....
>>
>> So, I need a way to pull out the rows (which vary daily) beneath the 
>> pound
>> row and place it in a new temp file that I can "cat >>" into a master 
>> file.
>>
>> Appreciate your kind help once again.... (beers on me!)
>>
>> All the best!
>> Jack
>>
>> (^_^)
>> Happy trails,
>> Jack L. Stone
>>
>> System Admin
>> Sage-america
> awk is your friend .-)
> this script does exactly what you need
> extract.awk
> ---------------
> /^#####+$/ {
>    getline;
>    while (match($0, "^[[:print:]]+$")) {
>        print $0;
>        getline;
>    }
> }
> ---------------
> You can still adjust the pattern in match to suit your need.
> invoke it with
> awk -f extract.awk yourfile
>
> Andreas
I forgot to remove some extra output :-)

-- 
Dr.-Ing. Andreas Haakh
Schwanengasse 13  *  64380 Roßdorf  *  andreas@haakh.de
Tel. 06154-694822 Fax. 06154-694821 Mobil 0173-361.6884




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C6BF944.5060302>