From owner-freebsd-questions@FreeBSD.ORG Thu Nov 6 17:27:54 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 DBCCAD71 for ; Thu, 6 Nov 2014 17:27:54 +0000 (UTC) Received: from smtpb.telissant.net (smtpb.telissant.net [199.233.230.156]) by mx1.freebsd.org (Postfix) with ESMTP id ADBB8D84 for ; Thu, 6 Nov 2014 17:27:53 +0000 (UTC) Received: from barrida.3dresearch.com (localhost [127.0.0.1]) by smtpb.telissant.net (Postfix) with ESMTP id 71B9827372 for ; Thu, 6 Nov 2014 12:27:53 -0500 (EST) X-Virus-Scanned: amavisd-new at telissant.net Received: from smtpb.telissant.net ([127.0.0.1]) by barrida.3dresearch.com (barrida.3dresearch.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OKm0IlBK1jfN for ; Thu, 6 Nov 2014 12:27:38 -0500 (EST) Received: from doncurzio.3dresearch.com (pool-71-112-0-222.pitbpa.east.verizon.net [71.112.0.222]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtpb.telissant.net (Postfix) with ESMTPSA id D71632731E for ; Thu, 6 Nov 2014 12:27:37 -0500 (EST) Received: from doncurzio.3dresearch.com (localhost [127.0.0.1]) by doncurzio.3dresearch.com (Postfix) with SMTP id 3EC80A1E2C for ; Thu, 6 Nov 2014 12:27:37 -0500 (EST) Date: Thu, 6 Nov 2014 12:24:41 -0500 From: Janos Dohanics To: FreeBSD Questions Subject: Re: uniq(1) on last field Message-Id: <20141106122441.bcda9b772b499a6ff0f378d1@3dresearch.com> In-Reply-To: References: <20141106110319.eb34eaa069a4881824072010@3dresearch.com> X-Mailer: Sylpheed 3.3.0 (GTK+ 2.24.19; amd64-portbld-freebsd9.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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:27:54 -0000 On Thu, 6 Nov 2014 17:42:40 +0100 Peter Boosten wrote: > > > > > > > I would like to use uniq(1) on the file name, which is of course the > > last field if / is used as field separator. > > > > How can I tell uniq(1) the "last field" if I have variable number of > > fields? > > > sort -u might be a better option > > -- > Peter Boosten Thanks. I'd have to use something like 'sort -k [n] -u'. Seems that awk -F "/" '{print NF}' gives the value for n, but what would be the syntax for that sort command? -- Janos Dohanics