Date: Fri, 13 Aug 2010 09:28:12 -0700 From: merlyn@stonehenge.com (Randal L. Schwartz) To: lconrad@Go2France.com Cc: freebsd-questions@freebsd.org Subject: Re: awk problem Message-ID: <8639uipjdv.fsf@red.stonehenge.com> In-Reply-To: <201008131723.AA679149726@mail.Go2France.com> (Len Conrad's message of "Fri, 13 Aug 2010 17:23:06 %2B0200") References: <201008131723.AA679149726@mail.Go2France.com>
next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> "Len" == Len Conrad <lconrad@Go2France.com> 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 <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8639uipjdv.fsf>