help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: uniq ignore blank lines?


From: casioculture
Subject: Re: uniq ignore blank lines?
Date: 26 Dec 2005 19:37:53 -0800
User-agent: G2/0.2

Paul Jarc wrote:
> casioculture@gmail.com wrote:
> > How can I instruct uniq to ignore blank lines?
>
> Do you mean you want them to be removed entirely, or preserved even
> when there are multiple consecutive ones?
>
>
> paul

Not removed entirely from the file itself, but from the output of the
uniq utility report. I keep a textfile in which to give visual emphasis
to some lines I duplicate them a few times. I want to use uniq utility
to make a little report of the duplicate contents of the file, so far I
know I need to use something like

uniq -c -d file

But the problem is that it reports the leading lines too. I found a
sortu utility online that has a -b option to ignore blank lines but i'd
rather use the standard ones.

I just did a piping

sort file | uniq -c -d | sort -r

This gives me the duplicated lines in my file sorted by how many times
they're duplicated, but the first item I get are how many blank lines
there are in my file, which I don't need to know.

Can I improve on this?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]