From owner-freebsd-questions@freebsd.org Sat Apr 15 19:51:03 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 373FBD3F3BC for ; Sat, 15 Apr 2017 19:51:03 +0000 (UTC) (envelope-from andipersti@gmail.com) Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) (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 CA74666C for ; Sat, 15 Apr 2017 19:51:02 +0000 (UTC) (envelope-from andipersti@gmail.com) Received: by mail-wr0-x242.google.com with SMTP id l28so16078432wre.0 for ; Sat, 15 Apr 2017 12:51:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sHaWgWzaiSDoD9CR4Ir6SWs2qumAwuvsJVpdoFBpN4U=; b=goTHtc/B2m2qNzkKgJ+9KNrTZqqFIkB5BHI4ruFALZ+MEHvomsO0XCNZObY1w7S8// 1QDNfQrb/n+NL2/5/8oEJOLH3+tBgJX39FMAf2r12RXSTpSFJMVwj2fd5DDd6qGfJd4w 3SQaNSZZ4UV9wdOezXqxpSAJJzCI8qRd7dfbtN98/RBzRgiS5Y4XZXGEh5oST1B1SJ1E hYkqVa0gxyJ82MhTmiQp5OmsA6paGyu5NyUStpnM6PG7NgthpWcX5uipAKXvPH1lh9pZ KsECiQgP0NelTtQsgv3Sp0juhPSkkcajUl35g3BenxbyMQB0fN4BYVLD9efSLG+NNV/M C57w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sHaWgWzaiSDoD9CR4Ir6SWs2qumAwuvsJVpdoFBpN4U=; b=oZ/tibqUx7QbeROO8EV7VMJ/insCGZMtu24QE4B1AHH2eyen0yAggwied2iOcPm4VE 9Ev0UI0uYB9wVe7C8N178zf8Y1N2JIHnPr6H3WlhMI44j5LwsJXRSiwQASo8rUj4dcSx YSK/Yfi9cOk6O1HM/lAzTnC7/I/pf0K93/16jDT8qlVmqADLtsoY4GeIs93vEFyWKK2z gJFSOj3FOIyzymgVETViD6rYVszNH7k+ykqupnY3DbRd/WfZRRiFptkGj8oH+8Qt0h+v BD1eaggobglI5bj8fkba1LH5BZQicTbD57yk/OBRoy55vVkSsoUbJtwesVox9m8XlgAS tY5w== X-Gm-Message-State: AN3rC/6fVoVUyu+ngtImGFGZ+dhHzeKYyKfpDzmIADwMuef+cvGUz5qs WV6fs77uP5m/DP4s X-Received: by 10.223.164.221 with SMTP id h29mr13235052wrb.102.1492285859788; Sat, 15 Apr 2017 12:50:59 -0700 (PDT) Received: from Hof (193-81-168-198.hdsl.highway.telekom.at. [193.81.168.198]) by smtp.gmail.com with ESMTPSA id m21sm3705393wma.19.2017.04.15.12.50.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Apr 2017 12:50:59 -0700 (PDT) Date: Sat, 15 Apr 2017 21:50:56 +0200 From: Andreas Perstinger To: freebsd-questions@freebsd.org Subject: Re: awk help Message-ID: <20170415215056.6ab57316@Hof> In-Reply-To: <58F25A01.1060208@gmail.com> References: <58F25A01.1060208@gmail.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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 19:51:03 -0000 Ernie Luzar wrote: >I can't figure out how to code awk to process the 2 lines as a pair. You could use awk's built-in "getline" function in order to process the following line after you are done with the current one: $ cat awk_help.txt 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 2 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 3 Bytes 0 Name Ref 2 $ awk '/Address/ {address = substr($2, 1, length($2)-3); getline; if ($2) printf "%s;\t%s\n", address, $2}' awk_help.txt 1.163.139.214; 2 99.197.14.34; 3 Bye, Andreas