[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFE: uniq --sequential
From: |
Assaf Gordon |
Subject: |
Re: RFE: uniq --sequential |
Date: |
Wed, 10 Jun 2015 17:29:14 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
Hello Daiki,
On 06/10/2015 05:04 PM, Daiki Ueno wrote:
Hello,
I occasionally have to deal with sequential numbers which is largely
contiguous, but contain gaps (e.g., Unicode code points).
<...>
$ { seq 1 10; seq 12 22; seq 26 34; } | uniq --sequential
1
12
26
Perhaps the following will suffice?
$ { seq 1 10; seq 12 22; seq 26 34; } | awk 'A&&(A+1)!=$1 {print} 1 {A=$1}'
12
26
Or, if you want to print the first value as well:
$ { seq 1 10; seq 12 22; seq 26 34; } | awk 'NR==1{print}
A&&(A+1)!=$1{print} 1{A=$1}'
1
12
26
-assaf