From owner-freebsd-questions@freebsd.org Mon Apr 17 16:09:02 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 D7C82D423AD for ; Mon, 17 Apr 2017 16:09:02 +0000 (UTC) (envelope-from andipersti@gmail.com) Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (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 6A83E37E for ; Mon, 17 Apr 2017 16:09:02 +0000 (UTC) (envelope-from andipersti@gmail.com) Received: by mail-wm0-x234.google.com with SMTP id o81so36810058wmb.1 for ; Mon, 17 Apr 2017 09:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=3J6568TZRAcLPBxK9FYFQph+k75l16C79VEHUsJoMus=; b=cNzstG+BBjQrSti/N42M9oJu3IgSAxPnt2N3MhxM1FgmjS89ecucP2KZcPmeNmOnHz 4j0dbIEXDWjcCY4MrxwaQbpzF2FkG4E0xfiJzJ+JQw/SCxDHcpxJd2Ou8jjTJy3ZgcsA R4sEO8j83uu9VNutB+oALP8Z+3oaBalBh1WibQmOT9vd0zcMFXvMQm55LO4HszetHntd iLXtjcj4vLerADCM8U85f6r/dwVfNVt6wqwxYJBgTBiQfMocDeRNfHWt8xyrgfwnOui/ nbG4vGIUIQbxyISXPjHfExmGM+e49Cld4CGMSuf6Skc2TAimoxhkDxDXkWN+9bzWUlwp qeRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3J6568TZRAcLPBxK9FYFQph+k75l16C79VEHUsJoMus=; b=l2nMFfohghMzP2pun5Jl4uvVfYGUcynrocK3NCo8QoVvxh0BtlOJQraYjLooUfXF1i qEq0x+ud/TyftLdxWV+LFhNhJTp+yE+H/w7Tmb/MecAa1jYahCObttKnSAVtwLmFrz1y eSv7IVsA7mrKg53pkqoTNHDyazpaGnMLZ8/eV9tc75IP8Jo9jhK5v1KWhTXUJx4KVDad IWjlfZ5z2By94bTaum9U7NVO3hg3F8uOWgI9/UP+ifeKprqRx/WRQYGC2nY7x8eGLJmR JZO4Gqpvl0KuUhHKCrCllaGvtpmBPlMPb4eZ8dMhgKu2qrhxbAtzegkDxWvyV+OnXlUl MQsQ== X-Gm-Message-State: AN3rC/6Vi/xgXfT37r/SQDFcA/lq1mid9iq86SwVx2OOWi29SfWTnU/6 KJOMl6cO+lG1Yn8E X-Received: by 10.28.45.216 with SMTP id t207mr9737494wmt.85.1492445340475; Mon, 17 Apr 2017 09:09:00 -0700 (PDT) Received: from [192.168.178.25] (91-119-212-211.dsl.dynamic.surfer.at. [91.119.212.211]) by smtp.googlemail.com with ESMTPSA id h65sm14816769wrh.32.2017.04.17.09.08.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Apr 2017 09:08:59 -0700 (PDT) Subject: Re: awk help To: freebsd-questions@freebsd.org References: <58F25A01.1060208@gmail.com> <7951DF71-5CD3-4B53-9CB4-13CAA8945983@huiekin.org> <58F4CD14.7090008@gmail.com> From: Andreas Perstinger Message-ID: Date: Mon, 17 Apr 2017 18:08:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 MIME-Version: 1.0 In-Reply-To: <58F4CD14.7090008@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de_AT 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 16:09:02 -0000 On 2017-04-17 16:11, Ernie Luzar wrote: > 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? "^" inside a regular expression is an anchor and matches the beginning of the line. (See "man re_format" or e.g. http://www.regular-expressions.info/anchors.html ). In the example you've posted, the lines containing "Address" and "Hits" are indented which means there are spaces/tabs between the beginning of the line and these words. Thus the patterns don't match. > 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 You need to use the built-in function "system" in order to use system commands, e.g. system("rm " hits_yes) This concatenates the literal string "rm " with the content of the awk variable "hits_yes" which results in the string "rm /etc/ipf_pool_awk_hits_yes" and this command is then executed. > 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? The "date" command works without using the "system" function because it is part of the special syntax for the "getline" function. But I wonder whether you really need to use commands like "rm" and "touch" inside an awk script. What are you trying to accomplish? Bye, Andreas