uniq(1) on last field
Janos Dohanics
web at 3dresearch.com
Fri Nov 7 05:16:25 UTC 2014
On Thu, 6 Nov 2014 13:20:37 -0600
Alex Stangl <alex at 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
More information about the freebsd-questions
mailing list