I have data that looks like this:
0 1 0 0
0 0 0 1
0 0 0 1
0 1 0 0
I want to print all directly subsequent rows with 1s in the same column, using awk. How would I do this?
EDIT:
Is there no way within awk to specify the previous column, something like “$1-1” (I know thats wrong btw)?
I assumed that there is exact one
1per line.Further assuming your data is in data.input.
usage:
foo.awk: