Hello all,
I am a new (very new) user of awk and I am trying to write a if statement that will store a value in a variable, skip to the next line and store that same value (but different line) and then compare the two. If they are equal then loop again, if they are not equal then print the line. I will show you what the data looks like. I am looking at the hour/minute field. I want to be able to only print out the line when the first value on each minute changes. I want to skip the repeats of the minute. Thanks for the help.
05 09 2006 0627 26 59.9890-111 25.715 396
05 09 2006 0627 26 59.9790-111 25.696 397
05 09 2006 0627 26 59.9690-111 25.677 398
05 09 2006 0627 26 59.9580-111 25.657 399
05 09 2006 0628 26 59.9480-111 25.638 400
05 09 2006 0628 26 59.9370-111 25.619 401
05 09 2006 0628 26 59.9260-111 25.599 402
05 09 2006 0628 26 59.9150-111 25.580 403
05 09 2006 0628 26 59.9050-111 25.561 404
05 09 2006 0629 26 59.8950-111 25.541 405
05 09 2006 0629 26 59.8860-111 25.521 406
05 09 2006 0629 26 59.8770-111 25.500 407
05 09 2006 0629 26 59.8670-111 25.478 408
05 09 2006 0630 26 59.8580-111 25.458 409
05 09 2006 0630 26 59.8480-111 25.438 410
05 09 2006 0630 26 59.8370-111 25.418 411
05 09 2006 0630 26 59.8270-111 25.399 412
05 09 2006 0630 26 59.8150-111 25.380 413
05 09 2006 0631 26 59.8040-111 25.362 414
The hour/minute is the fourth field over looks like (0631)
This is what I have tried so far:
#!/usr/bin/awk -f
min = substr($0,14,1)
{next}
min2 = substr($0,14,1)
{
if (min != min2) print "$0"
else
next
}
I am a new (very new) user of awk and I am trying to write a if statement that will store a value in a variable, skip to the next line and store that same value (but different line) and then compare the two. If they are equal then loop again, if they are not equal then print the line. I will show you what the data looks like. I am looking at the hour/minute field. I want to be able to only print out the line when the first value on each minute changes. I want to skip the repeats of the minute. Thanks for the help.
05 09 2006 0627 26 59.9890-111 25.715 396
05 09 2006 0627 26 59.9790-111 25.696 397
05 09 2006 0627 26 59.9690-111 25.677 398
05 09 2006 0627 26 59.9580-111 25.657 399
05 09 2006 0628 26 59.9480-111 25.638 400
05 09 2006 0628 26 59.9370-111 25.619 401
05 09 2006 0628 26 59.9260-111 25.599 402
05 09 2006 0628 26 59.9150-111 25.580 403
05 09 2006 0628 26 59.9050-111 25.561 404
05 09 2006 0629 26 59.8950-111 25.541 405
05 09 2006 0629 26 59.8860-111 25.521 406
05 09 2006 0629 26 59.8770-111 25.500 407
05 09 2006 0629 26 59.8670-111 25.478 408
05 09 2006 0630 26 59.8580-111 25.458 409
05 09 2006 0630 26 59.8480-111 25.438 410
05 09 2006 0630 26 59.8370-111 25.418 411
05 09 2006 0630 26 59.8270-111 25.399 412
05 09 2006 0630 26 59.8150-111 25.380 413
05 09 2006 0631 26 59.8040-111 25.362 414
The hour/minute is the fourth field over looks like (0631)
This is what I have tried so far:
#!/usr/bin/awk -f
min = substr($0,14,1)
{next}
min2 = substr($0,14,1)
{
if (min != min2) print "$0"
else
next
}