Date: Fri, 7 Nov 2014 00:15:36 -0500 From: Janos Dohanics <web@3dresearch.com> To: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: uniq(1) on last field Message-ID: <20141107001536.4facb64ccb4606e919d0c780@3dresearch.com> In-Reply-To: <20141106192037.GA15248@scout.stangl.us> References: <20141106110319.eb34eaa069a4881824072010@3dresearch.com> <20141106184306.GA14996@scout.stangl.us> <20141106192037.GA15248@scout.stangl.us>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 6 Nov 2014 13:20:37 -0600 Alex Stangl <alex@stangl.us> wrote: > On Thu, Nov 06, 2014 at 12:43:06PM -0600, Alex Stangl wrote: > > 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'/' > > Or, even shorter, > > $ awk -F'/' '{printf "%s/%s\n", $NF, $0}' yourfile.txt | sort -k > '1,1' -u -t'/' | cut -f2- -d'/' > > > Alex Alex, works perfectly, thank you. Thank you everyone for your suggestions. -- Janos Dohanics
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141107001536.4facb64ccb4606e919d0c780>