From owner-freebsd-questions@FreeBSD.ORG Wed Aug 18 15:28:46 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43C9D1065694 for ; Wed, 18 Aug 2010 15:28:46 +0000 (UTC) (envelope-from andreas@Haakh.de) Received: from mo-p00-ob.rzone.de (mo-p00-ob.rzone.de [81.169.146.160]) by mx1.freebsd.org (Postfix) with ESMTP id B13D98FC1A for ; Wed, 18 Aug 2010 15:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1282145324; l=1636; s=domk; d=haakh.de; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References: Subject:CC:To:MIME-Version:From:Date:X-RZG-CLASS-ID:X-RZG-AUTH; bh=H7fB406mxTNN7q5n46NR1nsMlPc=; b=opfad4wjmps9wDlHbyUJl7BfJuNWdePaK1nrIypY4K6ZhTDqlewb1ocMsQalMbIMFIt wynnkMTeomLT5l+ejWAjIR/snCpE1tManeYBi+PbmcTwpBw/l0QU3Us7Qgxuyvgtq6pdz OwBSiKspiDkj7uInCI3ocTEYs31gmTQY3wc= X-RZG-AUTH: :LWQcbViwW/e6OTbW0dHzwKkCepY3+zAQY9KdRPw9VcHc3bN9H/P8W+bUBYo= X-RZG-CLASS-ID: mo00 Received: from abaton.Haakh.de (p57A74BB7.dip.t-dialin.net [87.167.75.183]) by post.strato.de (mrclete mo13) (RZmta 23.5) with ESMTP id y023f1m7IEY6zg ; Wed, 18 Aug 2010 17:16:43 +0200 (MEST) Received: from Crabberio.Haakh.de (crabberio.haakh.de [IPv6:2001:5c0:1508:1500:213:d4ff:fed0:bb7f]) by abaton.Haakh.de (8.14.4/8.14.4) with ESMTP id o7IFGgKG024988; Wed, 18 Aug 2010 17:16:42 +0200 (CEST) (envelope-from andreas@Haakh.de) Message-ID: <4C6BF944.5060302@Haakh.de> Date: Wed, 18 Aug 2010 17:16:20 +0200 From: "Dr. Andreas Haakh" User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; de-AT; rv:1.8.1.24) Gecko/20100812 SeaMonkey/1.1.19 MIME-Version: 1.0 To: "Jack L. Stone" References: <3.0.1.32.20100818084231.00ecef30@sage-american.com> <4C6BF8EA.3020406@Haakh.de> In-Reply-To: <4C6BF8EA.3020406@Haakh.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_HK_NAME_DR, T_RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on abaton.Haakh.de X-Mailman-Approved-At: Wed, 18 Aug 2010 15:52:17 +0000 Cc: freebsd-questions@freebsd.org Subject: Re: Extracting a variable listing X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2010 15:28:46 -0000 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