Date: Thu, 6 Nov 2014 18:32:50 +0100 From: Peter Boosten <peter@boosten.org> To: Janos Dohanics <web@3dresearch.com> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: uniq(1) on last field Message-ID: <33AF1AA1-9768-4D65-86A7-88A307AEFA5C@boosten.org> In-Reply-To: <C1660725-BF36-4F5F-9BA3-4E0231DB17A0@boosten.org> References: <20141106110319.eb34eaa069a4881824072010@3dresearch.com> <C1660725-BF36-4F5F-9BA3-4E0231DB17A0@boosten.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> On 6 nov. 2014, at 17:42, Peter Boosten <peter@boosten.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?33AF1AA1-9768-4D65-86A7-88A307AEFA5C>