From owner-freebsd-questions@freebsd.org Mon Apr 17 14:11:30 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 01088D4283F for ; Mon, 17 Apr 2017 14:11:30 +0000 (UTC) (envelope-from luzar722@gmail.com) Received: from mail-io0-x231.google.com (mail-io0-x231.google.com [IPv6:2607:f8b0:4001:c06::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 BD3218A0 for ; Mon, 17 Apr 2017 14:11:29 +0000 (UTC) (envelope-from luzar722@gmail.com) Received: by mail-io0-x231.google.com with SMTP id o22so30966797iod.3 for ; Mon, 17 Apr 2017 07:11:29 -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=dFApXtVYsQ9Hb4zMy30X15GQtanVKcGd1YurR+PizKw=; b=VXvsCpw5U+EwLInUge2vKU6iTGV78iGD5w0PJwutem50mdJ5VSBANZ4c/uLRC6mzLB AfRY82OwSbdJx7U6JZcBQ+3aFssRt6IH9PExWAyVHLPKzP+xMtIa2p4N9gZzCv0+RHO0 4WDoJ4ItX+MG2h9UzuuRFBJtZfIFqh666jfhQAZ9MKfADz4Exxb14H/xkwZpZ2O77dG6 UAciRxOoaYnrM7hws83J+fZDjlK/dOPpMdv8KUrFQscavl84ilXSJEr8ZvP32kVdA3ma tIEggLtOd73Ijnh3DLKD4TIxF9qiVb4/zQgGDrHoZyzRnPwiYW0mnHxUSdhUxQ7asQL3 2acA== 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=dFApXtVYsQ9Hb4zMy30X15GQtanVKcGd1YurR+PizKw=; b=VGHUCP/t3FV4Dzn2pIJAhBQTW06EqKimKPSPh3IbL3LoD8HmGaeY8b53F+qF/veN9o E1Rx39GNKO/fTl+Gj4vBnwBcqt4ys3j13ZdtCAFziGWXfbNB3FkTAh0nIAW0sTlnJLxC z0pAuac+iIlNfWPZ94o9FBIEeEODFwSKcZ02CaIOTMNfb0XW50qQlLtyO/2qXmmnoHJo ohFD5YL8+7h6ZnB9ZTQ2PajyCjffkDeIfvG6NkZq6imkWzJhaYgOnNExdFknEamRfVJ6 7B9XH8fUcnvFiaot3BxV9YdkJ2mtesXLWhXoVZTW2USSeYasNE+HUBtWQNo1AiPzm71J BHWg== X-Gm-Message-State: AN3rC/6QqLLQYSqFH86qyrI8LfZaQos7l4qzt3kMdTwxhMxT/ppr/Qcr uwWUidMd/SkQmLIQ X-Received: by 10.107.180.69 with SMTP id d66mr9518920iof.56.1492438287844; Mon, 17 Apr 2017 07:11:27 -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 g69sm3386708itg.17.2017.04.17.07.11.27 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Apr 2017 07:11:27 -0700 (PDT) Message-ID: <58F4CD14.7090008@gmail.com> Date: Mon, 17 Apr 2017 10:11:32 -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: Mon, 17 Apr 2017 14:11:30 -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 > Thank you Jim. Used this model as my starting point and accomplished my goal. When I first tested /^Address/ and /^ Hits/ produced no output. I changed them to /Address/ and /Hits/ and this produced output. I could not find any reference to the ^ sign, so I would like to know what is it suppose to do? I am not having success using the system commands rm & touch as shown in the following example. awk 'BEGIN { "date +%Y%m%d" | getline date hits_yes = "/etc/ipf_pool_awk_hits_yes" hits_no = "/etc/ipf_pool_awk_hits_no" rm hits_yes rm hits_no "touch hits_yes" "touch hits_no" }' $hits_rpt I know the date system command is working, but can't figure out how to code rm & touch to get them to work. Is this even possible? Thanks for any pointers.