From owner-freebsd-questions@freebsd.org Sat Apr 15 20:46:08 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8949DD3F9E5 for ; Sat, 15 Apr 2017 20:46:08 +0000 (UTC) (envelope-from luzar722@gmail.com) Received: from mail-it0-x231.google.com (mail-it0-x231.google.com [IPv6:2607:f8b0:4001:c0b::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 514D4925 for ; Sat, 15 Apr 2017 20:46:08 +0000 (UTC) (envelope-from luzar722@gmail.com) Received: by mail-it0-x231.google.com with SMTP id b15so9463186iti.1 for ; Sat, 15 Apr 2017 13:46:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-transfer-encoding; bh=bFz9rWzv5UIY/pg7/Ep6I/tGeGHnB1H5A9vMQieVuVw=; b=mUWKM5KHILAvGvDfvOGTzBs3r+l7Xc79rmENAPE7d4QwG55J7l0LP5G23nSc5SiUtM fvPH4F3eQHUk3INCM30Iaackiv1YxNj54riCCjR3CUOuC5h2/PJLyTnHB8Jq38N6eSQb kDycAVH+krNcRjet6Qg8nPZb7DfVJ4i1hyFX+DjLGT1/GUn1r7dfVUPCUqGQwGah2bb0 sOaPMQSAN2KdU1YuYbJMUJACanDRiGAEQaW4lW8XH919+15zNeEa8Y3gzJCJS51dVp7U 1K8gxrv4tAKcxxv0bYpRAjeL5WAY2C816BSw0kkq4ySfUGX39+QKt34Q9axVO/nREQ6c oUrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-transfer-encoding; bh=bFz9rWzv5UIY/pg7/Ep6I/tGeGHnB1H5A9vMQieVuVw=; b=GQCdMU1zFMgHuvnlGaIUs6QqOvDL1OoKZt0KSZq/36x45DlA8PfbSPPhYqxkM2fXCL O2vhiKi26UOsPYVkwPenVsupw5lqQ4m00C7CgIZFAXVH/HqPWKjA/X1SIbklzieyP35D G/uYH3UgT3rKQ6Wdw6saLl8E4k3kY1OlHg18Ucp92etBa9TeoGSvEsn2o+gH1lC2lqia Ea1ty0VnjP/n8PRfJdycyCPdLImLDbyDFUVLxWDyDRKLGxyKQIV2d78ch8bdXp5fIQFj J6oNQHqgcZNmUOuR4dsiJBGHnJrCAmfD5W5Z3s79asrMt8oCK+dIxLyGNI1BjcmU3hPJ NRWA== X-Gm-Message-State: AN3rC/6Bx5P7G0kGVech+ke94jcuXkzvLkkniZSv5bXZkpohZ2uSB7qJ G1/QygQktX0y9STy X-Received: by 10.36.57.86 with SMTP id l83mr3174915ita.5.1492289167749; Sat, 15 Apr 2017 13:46:07 -0700 (PDT) Received: from [10.0.10.3] (cpe-74-141-88-57.neo.res.rr.com. [74.141.88.57]) by smtp.googlemail.com with ESMTPSA id b126sm2830639ioa.55.2017.04.15.13.46.06 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 15 Apr 2017 13:46:07 -0700 (PDT) Message-ID: <58F28697.4040803@gmail.com> Date: Sat, 15 Apr 2017 16:46:15 -0400 From: Ernie Luzar User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Jim Trigg CC: freebsd-questions@freebsd.org Subject: Re: awk help References: <58F25A01.1060208@gmail.com> <7951DF71-5CD3-4B53-9CB4-13CAA8945983@huiekin.org> In-Reply-To: <7951DF71-5CD3-4B53-9CB4-13CAA8945983@huiekin.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Apr 2017 20:46:08 -0000 >> On April 15, 2017 1:36:01 PM EDT, Ernie Luzar wrote: >> Hello list; >> >> Can not figure how to process 2 lines as a single line. >> I have this file. >> >> poollist: opts = 0x2 >> Name: test Role: ipf References: 2 Hits: 0 >> Nodes Starting at 0xc9fd4800 >> Address: 1.11.244.65/32 >> Hits 0 Bytes 0 Name Ref 2 >> Address: 1.163.113.139/32 >> Hits 0 Bytes 0 Name Ref 2 >> Address: 1.163.139.214/32 >> Hits 0 Bytes 0 Name Ref 2 >> Address: 1.173.51.202/32 >> Hits 0 Bytes 0 Name Ref 2 >> Address: 1.175.164.129/32 >> Hits 0 Bytes 0 Name Ref 2 >> Address: 99.197.14.34/32 >> Hits 0 Bytes 0 Name Ref 2 >> >> The Address line and the Hits line makes a pair. >> >> For any pair that hits is greater than zero >> output file with ip address with ; sufix instead of /32 and >> hit value in fixed position. >> >> I can't figure out how to code awk to process the 2 lines as a pair. >> >> All ready searched the online awk references and could not find an >> example. Any pointers would sure help. >> >> Thanks > Jim Trigg wrote: > /^Address/ { address = $2; got_address = 1; } > /^ Hits/ { if (got_address) { > hits = $2; > if (hits) { > [Do what's needed with address and hits] > got_address = 0; > } else { > [Handle error condition of hits without address] > } > } > > Jim > In awk talk what is this called /^Address/ /^ Hits/ Thanks