From owner-freebsd-questions@FreeBSD.ORG Fri Aug 13 16:28:12 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4AF210656A5 for ; Fri, 13 Aug 2010 16:28:12 +0000 (UTC) (envelope-from merlyn@stonehenge.com) Received: from red.stonehenge.com (red.stonehenge.com [IPv6:2607:f2f8:3080::]) by mx1.freebsd.org (Postfix) with ESMTP id 8D87B8FC08 for ; Fri, 13 Aug 2010 16:28:12 +0000 (UTC) Received: by red.stonehenge.com (Postfix, from userid 1001) id 599F344E4F; Fri, 13 Aug 2010 09:28:12 -0700 (PDT) From: merlyn@stonehenge.com (Randal L. Schwartz) To: lconrad@Go2France.com References: <201008131723.AA679149726@mail.Go2France.com> x-mayan-date: Long count = 12.19.17.10.19; tzolkin = 1 Cauac; haab = 12 Yaxkin Date: Fri, 13 Aug 2010 09:28:12 -0700 In-Reply-To: <201008131723.AA679149726@mail.Go2France.com> (Len Conrad's message of "Fri, 13 Aug 2010 17:23:06 +0200") Message-ID: <8639uipjdv.fsf@red.stonehenge.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-questions@freebsd.org Subject: Re: awk problem X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2010 16:28:12 -0000 >>>>> "Len" == Len Conrad writes: Len> I readfile or pipe this text, in any line order: Len> rm90.steampick.info Len> fgce172.lanejive.info Len> smailer1.service.govdelivery.com Len> fl49.orangetalon.info Len> pollux.carespecial.info Len> into a program to remove subdomains down to domain.tld : Len> awk 'FS="." { print $(NF-1)"."$NF }' Len> and get the first line doubled rather than processed like the other lines: Len> rm90.steampick.info.rm90.steampick.info Len> lanejive.info Len> govdelivery.com Len> orangetalon.info Len> carespecial.info Yes, that would be the expected behavior. You need to set the FS *before* processing the first line. Either use -F ., or a BEGIN block. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion