## test column values

## test column values

(OP)

I've file with 2 columns

Cla Clb

5301 1922

5301 1923

5301 1925

5311 2020

5311 2021

5311 2022

5321 1880

5321 1885

5321 1886

5321 1887

... ...

I need to find cumul of diffrence values upper than 1 on column b with the same value of column a

if value of Cla is the same ex: 5301 do (1925-1923=2),(1923-1922=1) : cumul difference > 1 is equal 1 so cumul1=1

second value of Cla 5311 do (2022-2021=1), (2021-2020=1) : cumul difference > 1 is 0 so cumul2=0

third value of Cla 5321 (1887-1886=1), (1886-1885=1); (1885-1880=5) cumul difference > 1 is 1 so cumul3=1

at the end I'll calculate cumul1+cumul2+cumul3+...cumuln

using bash script or awk

attached wall file test

thanks for your help

Cla Clb

5301 1922

5301 1923

5301 1925

5311 2020

5311 2021

5311 2022

5321 1880

5321 1885

5321 1886

5321 1887

... ...

I need to find cumul of diffrence values upper than 1 on column b with the same value of column a

if value of Cla is the same ex: 5301 do (1925-1923=2),(1923-1922=1) : cumul difference > 1 is equal 1 so cumul1=1

second value of Cla 5311 do (2022-2021=1), (2021-2020=1) : cumul difference > 1 is 0 so cumul2=0

third value of Cla 5321 (1887-1886=1), (1886-1885=1); (1885-1880=5) cumul difference > 1 is 1 so cumul3=1

at the end I'll calculate cumul1+cumul2+cumul3+...cumuln

using bash script or awk

attached wall file test

thanks for your help

## RE: test column values

So if there is at least one case when the difference between consecutive Clb values is greater than 1, then the cumul of the given Cla group is 1, otherwise 0 ?

## CODE --> Awk

Feherke.

feherke.ga

## RE: test column values

the programm work but it do not the cumul like I need. in my example:

5301 1922

5301 1923

5301 1925

5301 1927

5311 2020

5311 2021

5311 2022

5311 2024

5321 1880

5321 1885

5321 1886

5321 1887

ze test :

for $1=5301 we have (1923-1922=1); (1925-1923)=2; (1927-1925=2) cumul difference must be >1 cumul1= 0+2-1+2-1=2

for $1=5311 we have (2021-2020=0);(2022-2021=0);(2024-2022=2) cumul difference > 1 cumul2= 0+0+2-1=1

for $1=5321 we have (1887-1886=1);(1886-1885=1);(1885-1880=5) cumul difference > 1 cumul3= 0+0+5-1=4

the program do just one operation of difference

so

for a value of Cla we do val(n)-val(n-1)=a1; val(n-1)-val(n-2)=a2;...... and the cumul is if diff > 1 a1-1+a2-1+a3-1+.....

thanks a lot

execuse me for my longue explanation

## RE: test column values

Not really sure as I can not find the relation between your

"we have"values and"cumulX="values, but maybe this :## CODE --> Awk

Feherke.

feherke.ga

## RE: test column values

thank you so much quick reply and your interest.

good luck