Python's simplicity philosophy
Ben Finney
bignose-hates-spam at and-benfinney-does-too.id.au
Thu Nov 20 17:00:14 EST 2003
On 20 Nov 2003 16:25:08 +0100, Curt wrote:
> Erik Max Francis <max at alcyone.com> writes:
>> [Unix command] uniq doesn't care whether the input is sorted or not.
>> All it does is collapse multiple consecutive duplicate lines into a
>> single line. Using uniq in conjunction with sort is certainly a
>> common mode, but it's hardly required.
>
> curty at einstein:~$ less uniq.txt
> flirty
> curty
> flirty
> curty
>
> curty at einstein:~$ uniq uniq.txt
> flirty
> curty
> flirty
> curty
>
> curty at einstein:~$ sort uniq.txt | uniq
> curty
> flirty
>
> Maybe my uniq is unique.
>
> curty at einstein:~$ man uniq
>
> NAME
> uniq - remove duplicate lines from a sorted file
I suspect your uniq is not unique; merely poorly documented. Pass it a
file consisting of unsorted input, but multiple consecutive identical
lines; you should see them collapsed to one.
Your OS needs a better 'man uniq', since that description doesn't say
what the expected behaviour is with unsorted input. The GNU 'man uniq'
doesn't mention sorted input, but applies to any input.
--
\ "Theology is the effort to explain the unknowable in terms of |
`\ the not worth knowing." -- Henry L. Mencken |
_o__) |
Ben Finney <http://bignose.squidly.org/>
More information about the Python-list
mailing list