From owner-freebsd-questions@FreeBSD.ORG Thu Nov 6 18:43:13 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5F83049E for ; Thu, 6 Nov 2014 18:43:13 +0000 (UTC) Received: from stangl.us (stangl.us [66.93.193.95]) by mx1.freebsd.org (Postfix) with ESMTP id 2B78681E for ; Thu, 6 Nov 2014 18:43:12 +0000 (UTC) Received: from scout.stangl.us (localhost [127.0.0.1]) by scout.stangl.us (Postfix) with ESMTP id 81D9F17022 for ; Thu, 6 Nov 2014 12:43:06 -0600 (CST) X-Virus-Scanned: amavisd-new at stangl.us Received: from stangl.us ([127.0.0.1]) by scout.stangl.us (scout.stangl.us [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OSf9rEoaUVyE for ; Thu, 6 Nov 2014 12:43:06 -0600 (CST) Received: by scout.stangl.us (Postfix, from userid 1001) id 15F0C1701A; Thu, 6 Nov 2014 12:43:06 -0600 (CST) Date: Thu, 6 Nov 2014 12:43:06 -0600 From: Alex Stangl To: freebsd-questions@freebsd.org Subject: Re: uniq(1) on last field Message-ID: <20141106184306.GA14996@scout.stangl.us> Mail-Followup-To: freebsd-questions@freebsd.org References: <20141106110319.eb34eaa069a4881824072010@3dresearch.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141106110319.eb34eaa069a4881824072010@3dresearch.com> User-Agent: Mutt/1.5.23 (2014-03-12) 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 18:43:13 -0000 On Thu, Nov 06, 2014 at 11:03:19AM -0500, Janos Dohanics wrote: > Would you please help with a shell scripting problem. I have a samba > audit log file which after some parsing has entries like this: > > Nov 5 15:07:10 testuser 10.10.10.72 pluto pwrite ok COMMON/Solidworks Parts & Assemblies/CDE - Beck/Tube Baffle Coalescer Model/~$40in OD Shell.SLDPRT > > I would like to use uniq(1) on the file name, which is of course the > last field if / is used as field separator. $ awk -F'/' '{printf "%s%s%s\n", $NF, "/", $0}' yourfile.txt | sort -k '1,1' -u -t'/' | cut -f2- -d'/' Alex