From owner-freebsd-questions@FreeBSD.ORG Thu Nov 6 17:56:00 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 94A53724 for ; Thu, 6 Nov 2014 17:56:00 +0000 (UTC) Received: from smtpq1.gn.mail.iss.as9143.net (smtpq1.gn.mail.iss.as9143.net [212.54.34.164]) by mx1.freebsd.org (Postfix) with ESMTP id 4A72CC7 for ; Thu, 6 Nov 2014 17:55:59 +0000 (UTC) Received: from [212.54.34.134] (helo=smtp3.gn.mail.iss.as9143.net) by smtpq1.gn.mail.iss.as9143.net with esmtp (Exim 4.71) (envelope-from ) id 1XmQvY-0000xt-LX; Thu, 06 Nov 2014 18:32:56 +0100 Received: from 5419839c.cm-5-2c.dynamic.ziggo.nl ([84.25.131.156] helo=ra.boosten.org) by smtp3.gn.mail.iss.as9143.net with esmtp (Exim 4.71) (envelope-from ) id 1XmQvY-0007GI-BX; Thu, 06 Nov 2014 18:32:56 +0100 Received: from ra.egypt.nl (localhost.egypt.nl [127.0.0.1]) by ra.boosten.org (Postfix) with ESMTP id 92FC5398E0; Thu, 6 Nov 2014 18:32:53 +0100 (CET) X-Virus-Scanned: amavisd-new at boosten.org Received: from ra.boosten.org ([127.0.0.1]) by ra.egypt.nl (ra.egypt.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e4qgOl_soX_9; Thu, 6 Nov 2014 18:32:52 +0100 (CET) Received: from mbp.egypt.nl (mbp.egypt.nl [192.168.13.33]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ra.boosten.org (Postfix) with ESMTPSA id E6C0539860; Thu, 6 Nov 2014 18:32:52 +0100 (CET) Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) Subject: Re: uniq(1) on last field From: Peter Boosten In-Reply-To: Date: Thu, 6 Nov 2014 18:32:50 +0100 Message-Id: <33AF1AA1-9768-4D65-86A7-88A307AEFA5C@boosten.org> References: <20141106110319.eb34eaa069a4881824072010@3dresearch.com> To: Janos Dohanics X-Mailer: Apple Mail (2.1990.1) X-Ziggo-spambar: ---- X-Ziggo-spamscore: -4.9 X-Ziggo-spamreport: ALL_TRUSTED=-1, BAYES_00=-1.9, HTML_MESSAGE=0.001, PROLO_TRUST_RDNS=-3, RDNS_DYNAMIC=0.982, SPF_PASS=-0.001 X-Ziggo-Spam-Status: No X-Spam-Status: No X-Spam-Flag: No Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: FreeBSD Questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2014 17:56:00 -0000 > On 6 nov. 2014, at 17:42, Peter Boosten wrote: >=20 >=20 >>=20 >>=20 >> I would like to use uniq(1) on the file name, which is of course the >> last field if / is used as field separator.=20 >>=20 >> How can I tell uniq(1) the "last field" if I have variable number of >> fields? >=20 >=20 > sort -u might be a better option >=20 Ah, I missed the =E2=80=98variable number of fields=E2=80=99=E2=80=A6 What is it you=E2=80=99re trying to show? Since the line in itself = always is unique. If you only want to show the file name, you could use = awk =E2=80=98{print $NF}=E2=80=99 to show the last field, end pipe that = through uniq. so: awk =E2=80=98{print $NF}=E2=80=99 file | uniq (-c if you want to count = them) I don=E2=80=99t think either uniq nor sort have any notion of 'last = field=E2=80=99 in a variable field situation.=20 --=20 Peter Boosten