Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 Oct 2015 00:13:55 -0400
From:      Jim Trigg <jtrigg@huiekin.org>
To:        Polytropon <freebsd@edvax.de>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: awk question
Message-ID:  <EBFF44B4-EF90-4C39-B06D-54FF20FBB019@huiekin.org>
In-Reply-To: <20151005235812.eee38247.freebsd@edvax.de>
References:  <5611C922.4050007@hiwaay.net> <20151005042129.1f153ec6.freebsd@edvax.de> <5611F776.9090701@hiwaay.net> <56124479.9020505@sneakertech.com> <20151005165902.ad01c288.freebsd@edvax.de> <5612EF57.10207@sneakertech.com> <20151005235812.eee38247.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Frighteningly enough, the syntax "< file  command" does work...

Jim

On October 5, 2015 5:58:12 PM EDT, Polytropon <freebsd@edvax.de> wrote:
>On Mon, 05 Oct 2015 17:44:55 -0400, Quartz wrote:
>> 
>> > The form "input | step1 | step2 | step3 | step4>  result" usually
>> > is more readable
>> 
>> That's what I meant my being easier to understand conceptually. I
>agree 
>> about being more readable- even though this format sometimes needs
>the 
>> 'useless cat' it's often my preferred coding style, especially in 
>> scripts where the input might change around.
>
>And the "useless cat" method also makes it easy to test the
>script with varying input (for example, pre-generated test
>input) before it "goes live". It also makes it easier to
>"extend" the pre- or post-processing commands with new ones.
>
>
>
>> > Additionally, awk isn't that hard to learn. Reading "man awk" will
>> > provide you with a good background. And if you're already a C
>> > programmer, you'll see that many things you can do in C will also
>> > work similarly in awk, which _might_ not even be a good thing. :-)
>> 
>> The problem with awk is the whole BEGIN/END/braces thing and how
>commas 
>> interact with the operands.
>
>It's not that hard:
>
>BEGIN { ... } will be executed _before_ any input is processed,
>END { ... } will be executed _after_ all input has been processed.
>/pattern/ { ... } will be executed for each matching input line,
>(condition) { ... } will be executed when the condition is true,
>and { ... } will be executed for _every_ input line.
>
>Regarding commas: You can use the "print a b c" form as well as
>the more sophisticated C-like printf("format string", a, b, c)
>form. For all other functions, commas are argument separators
>just like in many other programming languages.
>
>	% echo "a b c" | awk '{ print $3 $1 $2 }'
>	cab
>	% echo "a b c" | awk '{ print $3, $1, $2 }'
>	c a b
>	% echo "a b c" | awk '{ printf("%s-%s-%s\n", $3, $1, $2); }'
>	c-a-b
>
>Those are the three "main methods" of printing: concatenated,
>separated by a space, and custom formatted string. And the
>semicolon is optional, it's just my C-contamination. :-)
>
>
>> It's not very much like sh or C syntax (or 
>> any other syntax) and new users tend to get really confused.
>
>Hmmm... I don't know, could you provide an example where you
>would say, like, "this is not intuitive" or even "this does
>something totally strange"?
>
>
>
>> Also, different versions of awk handle math (esp floating point) with
>
>> different rounding/precision/overflow, making calculations vary
>between 
>> installations, only further adding to the confusion.
>
>Yes, this is true, but keep in mind what awk is: a "pattern-directed
>scanning and processing language". If you want higher precision
>math, use system("<math stuff> | dc") and incorporate the result;
>awk isn't really for math, but integer math is usually fine. :-)
>
>
>
>-- 
>Polytropon
>Magdeburg, Germany
>Happy FreeBSD user since 4.0
>Andra moi ennepe, Mousa, ...
>_______________________________________________
>freebsd-questions@freebsd.org mailing list
>https://lists.freebsd.org/mailman/listinfo/freebsd-questions
>To unsubscribe, send any mail to
>"freebsd-questions-unsubscribe@freebsd.org"

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
From owner-freebsd-questions@freebsd.org  Tue Oct  6 08:03:13 2015
Return-Path: <owner-freebsd-questions@freebsd.org>
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 C9C179B1310
 for <freebsd-questions@mailman.ysv.freebsd.org>;
 Tue,  6 Oct 2015 08:03:13 +0000 (UTC)
 (envelope-from axelbsd@ymail.com)
Received: from nm21-vm5.bullet.mail.ir2.yahoo.com
 (nm21-vm5.bullet.mail.ir2.yahoo.com [212.82.97.2])
 (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 0444D1A2E
 for <freebsd-questions@freebsd.org>; Tue,  6 Oct 2015 08:03:12 +0000 (UTC)
 (envelope-from axelbsd@ymail.com)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s2048;
 t=1444118383; bh=JaJMEoBnmrS7Hu5pVdwqq7gnqp+4LML+vgZ7LtV4Qro=;
 h=From:To:CC:Subject:Date:In-Reply-To:References:From:Subject;
 b=cZI6Ant1uWgehE097YED5KoPwbSGt52jGCm6MrUBvfaX9qJpxroC8MMPOc4Sq9F5EG9YzAu1mDP2/SKsxXk4jc5A9Z5uAH76slImSsoUs11ZvSOYVSDhYEXOgh/PRvdV5t629HjhsWYjE/SlwzpJwCoi7vG6c8my+433yfrmXkinpJQTXuQMcg9MW+Cd5oRoPLW3LNSDZsauEfz8eUoGLjZYQxyfoPqhtnL4AO6VMjqxvDPHAULfkug8Eyq4GUchq0jgpFyaL51UeFu9KfXYBcurJ4SRfIPlbEgU/Zv2w3S7gbAgJ1T3HL0UFNK9R8T+xDZCHVJO4TGDEpXrZnawpQ==
Received: from [212.82.98.126] by nm21.bullet.mail.ir2.yahoo.com with NNFMP;
 06 Oct 2015 07:59:43 -0000
Received: from [46.228.39.83] by tm19.bullet.mail.ir2.yahoo.com with NNFMP;
 06 Oct 2015 07:59:43 -0000
Received: from [127.0.0.1] by smtp120.mail.ir2.yahoo.com with NNFMP;
 06 Oct 2015 07:59:43 -0000
X-Yahoo-Newman-Id: 810744.81644.bm@smtp120.mail.ir2.yahoo.com
X-Yahoo-Newman-Property: ymail-3
X-YMail-OSG: NzlfwQEVM1lF9IA0ts0uUfVTktP6B5.SMbXUPAiJvYsp5Fw
 6gurm08jcwy.J4IcfMZ1x.N.KjZB5sr.4KKqRRMXa_GZP3srYZbwMyNuUFCv
 dNpqpB8ytOOEJbla3Q5pVSAPhw_xOTbgXNfnInja6bnWhwued7GBIW5Pl8rl
 tpXTXvTV6n3gG1rPkIDh99VAAIqj2B1tdsxi9tt_RJIA1IwoIIP8l2G4wLZL
 r01Wnj7NCGB3vY7JkZKCjXaXcZmZ_.X5BNjEdkyD3Y8RHYKnkWEcAuI14V0k
 L1yw_EQvaUuIcEmonijD.3busQvvpiTTpkvr2O4jeWD7RamDGtS0JDIvOLZ1
 Gwu4pi7krOm_P0PSxJ8hCX6cNHfvmhr60xdFlKSLF9rctfBJEhgpVC6HTuen
 ot7py1aJ2nwK_FVzXb8ycjuwOzsEYSpGH4TPsbyp6yujsvzTyYmUyldthFYv
 v.Ep44J6pVBB_5D9R27AQc.p6zOXOXwsu8NLDrAtiz3wOxdRMlOLmAORWvPr
 iRlzgazggWjtlr4WZ9YB136zeO9AG0TdV_V4gYnfC7hdhgEpGW5x1zA4-
X-Yahoo-SMTP: S65s63SswBDjU54Gjqw2GSWlZmfgiEU_X3tN1_9u
Received: from DUB118-W49 ([157.56.194.39]) by DUB004-WSS1S1.hotmail.com over
 TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); 
 Tue, 6 Oct 2015 00:59:43 -0700
X-TMN: [lmFlHZcpl85HrtL1s9kNmEQYNdpyWbth]
Message-ID: <DUB118-W49D62C6948C2D61F7E55CBB4370@phx.gbl>
From: Alexandre <axelbsd@ymail.com>
To: Nino J <nino80@gmail.com>
CC: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject: RE: SSHguard & IPFW
Date: Tue, 6 Oct 2015 09:59:43 +0200
Importance: Normal
In-Reply-To: <CALf6cgZYJxQQA5Dxtu2QKzRC7FebeXte7NNRmGwOa5ma7We=tQ@mail.gmail.com>
References: <DUB118-W2564316B09E855F03F7D11B44E0@phx.gbl>
 <1443531575.1236.13.camel@michaeleichorn.com>,
 <DUB118-W32603EFCC32F67913C02BEB44E0@phx.gbl>,
 <CALf6cgZYJxQQA5Dxtu2QKzRC7FebeXte7NNRmGwOa5ma7We=tQ@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginalArrivalTime: 06 Oct 2015 07:59:43.0324 (UTC)
 FILETIME=[F5C2B1C0:01D1000C]
X-BeenThere: freebsd-questions@freebsd.org
X-Mailman-Version: 2.1.20
Precedence: list
List-Id: User questions <freebsd-questions.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions/>;
List-Post: <mailto:freebsd-questions@freebsd.org>
List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Tue, 06 Oct 2015 08:03:14 -0000

________________________________=0A=
> From: nino80@gmail.com =0A=
> Date: Wed=2C 30 Sep 2015 09:41:55 +0200 =0A=
> Subject: Re: SSHguard & IPFW =0A=
> To: axelbsd@ymail.com =0A=
> CC: freebsd-questions@freebsd.org =0A=
>  =0A=
> On Tue=2C Sep 29=2C 2015 at 4:24 PM=2C Alexandre  =0A=
> <axelbsd@ymail.com<mailto:axelbsd@ymail.com>> wrote: =0A=
>  =0A=
> >> About the blocking rules reservation in IPFW (from rule 55000 to =0A=
> >> 55050)=2C anyone experienced yet full use of these rules? =0A=
> >> By default=2C fifteen addresses can be blocked together. But how SSHGU=
ARD =0A=
> >> works in this case for the newest one (51th)? =0A=
> >> =0A=
> >> Thank you in advance for your clarifications. =0A=
> >> Alexandre =0A=
>  =0A=
> To answer your second question=2C IPFW has no problem using the same rule=
  =0A=
> number for multiple rules. Thus sshguard is not limited to 50  =0A=
> addresses. =0A=
>  =0A=
> Also=2C next version of sshguard won't use IPFW rules=2C but rather an IP=
FW  =0A=
> table to insert IP addresses to be blocked. Thus it will only need a  =0A=
> single deny rule. =0A=
>  =0A=
> I'm currently using development version of sshguard which uses IPFW  =0A=
> table and it works fine for me. =0A=
>  =0A=
> Regards=2C =0A=
> --  =0A=
> Nino =0A=
>  =0A=
=0A=
Hi Nino=2C=0A=
=0A=
I encounter now an issue with IPFW and blacklist functionnality: when I res=
tart sshguard service (or reboot the machine)=2C I need to delete /var/db/s=
shguard/blacklist.db before launch sshguard service again.=0A=
It is a know issue as described here http://sourceforge.net/p/sshguard/mail=
man/message/34146342/=0A=
Do you know when the next security/sshguard-ipfw version will be in FreeBSD=
 ports?=0A=
=0A=
Thank you.=0A=
=0A=
Regards.=0A=
Alexandre=0A=
=0A=
 		 	   		  =




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?EBFF44B4-EF90-4C39-B06D-54FF20FBB019>