From owner-freebsd-bugs@FreeBSD.ORG Mon Feb 12 16:00:28 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8ABE616A402 for ; Mon, 12 Feb 2007 16:00:28 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 7A84113C47E for ; Mon, 12 Feb 2007 16:00:28 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l1CG0SYA023889 for ; Mon, 12 Feb 2007 16:00:28 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l1CG0Sh8023888; Mon, 12 Feb 2007 16:00:28 GMT (envelope-from gnats) Date: Mon, 12 Feb 2007 16:00:28 GMT Message-Id: <200702121600.l1CG0Sh8023888@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Kris Kennaway Cc: Subject: Re: misc/109047: cut utility reads off by one place when day (date) is a double digit X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Kris Kennaway List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Feb 2007 16:00:28 -0000 The following reply was made to PR bin/109047; it has been noted by GNATS. From: Kris Kennaway To: Tim Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: misc/109047: cut utility reads off by one place when day (date) is a double digit Date: Mon, 12 Feb 2007 10:57:02 -0500 On Sun, Feb 11, 2007 at 02:00:26PM +0000, Tim wrote: > When the day (date) reaches double digits the cut utility/program somehow reads the field as off by one. I'm not sure if this is a problem with the auth.log or with cut itself but my bet is on cut. > > I have a script that reads auth.log and filters out bad login attempts and writes to hosts.allow. When the date reaches double digits I have to adjust my script accordingly. > > Here is the offending line in my script. > > for IP in `grep sshd /var/log/auth.log|grep "illegal user"|cut -d " " -f14` 0.0.0.0; do > > I have to change the -f14 to -f13 during double digit days and then again when the month rolls over set it back to -f14. I think this is a bug in your expectation of how to use cut :-) As you have found (also how it is documented to work), cut treats each instance of the delimiter (" ") as separating a new field, so when spacing changes so does its idea of field counting. This is by design. If you want to extract a word without worrying about whitespace, use a different tool, a convenient one is awk '{print $14}' Kris