views:

132

answers:

2

'man uniq' documents the -f=N and -s=N options which make uniq skip the first N fields/characters respectively when comparing lines, but how would you force uniq to skip the last N fields/characters?

+7  A: 

rev $filename | sort | uniq -f=N | rev

ennuikiller
After that you'll have to pipe the output through `rev` again, to get some readable information.
tangens
yes tangens, thanks
ennuikiller
thanks to ghostdog for pointing out the necessity of sort!
ennuikiller
anyone care to come up with an argument as to why this behaviour isn't incorporated into uniq as a command line switch/option?
Julius
+2  A: 

you will need to sort your data first if you want to use uniq

 sort file | rev | uniq -f 10 | rev
ghostdog74
uniq without sort removes consecutive identical line which can definitely be useful.
R Samuel Klatchko