Sample input
If I want to extract list of lines for which $2==y I can do.
What I really need is to print the consecutive lines with the same third column value on the same line.
So the desired output is.
Alternative output that would suit me even better is
Any suggestions? Probably there is some special awk function that can compare values for the current record with the previous.
Thanks.
Code:
1 y 10
2 y 11
3 y 10
4 n 12
5 n 22
6 y 12
7 y 12
8 n 33
9 y 12
10 y 10
11 y 10
12 y 10
13 y 10
14 y 11
If I want to extract list of lines for which $2==y I can do.
Code:
awk '$2=="y"{print $1}' list
1
2
3
6
7
9
10
11
12
13
14
So the desired output is.
Code:
1
2
3
6 7
9
10 11 12 13
14
Code:
1
2
3
6 - 7
9
10 - 13
14
Thanks.