From owner-freebsd-questions@FreeBSD.ORG Wed Aug 18 15:15:24 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 6C972106564A for ; Wed, 18 Aug 2010 15:15:24 +0000 (UTC) (envelope-from bugReporter@Haakh.de) Received: from mo-p00-ob.rzone.de (mo-p00-ob.rzone.de [81.169.146.161]) by mx1.freebsd.org (Postfix) with ESMTP id E838C8FC18 for ; Wed, 18 Aug 2010 15:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1282144522; l=1382; 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=yOfzBegy0OjxQ+4+KWpGiMz8GpU=; b=ORLMKeo+n8tVzHURkYaGizk4gtIRogNKDkBenrFn7TkwiQHAn6UiaKYDk0fExMsD7tl jf9jqyuhben1hN3x1qK+beLTlM1HEUZ5LRflJasNgjHWzuNJpGuXjq7jzJ7BC8DDG+5xf y/JEopupFkkLHVRJ7K/YVQ5UaV1v67WLk7A= 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 mo24) (RZmta 23.5) with ESMTP id v02d58m7IF2IcJ ; Wed, 18 Aug 2010 17:15:18 +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 o7IFFCMo024965; Wed, 18 Aug 2010 17:15:13 +0200 (CEST) (envelope-from bugReporter@Haakh.de) Message-ID: <4C6BF8EA.3020406@Haakh.de> Date: Wed, 18 Aug 2010 17:14:50 +0200 From: "Dr. A. 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> In-Reply-To: <3.0.1.32.20100818084231.00ecef30@sage-american.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,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 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:15:24 -0000 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 --------------- /^#####+$/ { print $0; getline; print ">>>>>",$0 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