Hi all,
I am processing a file with awk that looks like this:
"
0.0021 etc
0.0123 etc
0.1234 etc
...
0.5324 etc
0.5434 etc
0.6543 etc
...
1.0344 etc
1.1344 etc
...
1.5345 etc
1.5632 etc
"
I need to print out only the lines that have '0' or '5' after the comma, plus I need only one occurrence of each pattern match. So, based on the structure above, I need this:
"
0.0021 etc
0.5324 etc
1.0344 etc
1.5345 etc
"
I managed to keep only the lines that have '0' or '5' after the comma with this regular expression (somewhere inside an "if" clause of an awk script):
$1~/0\.0/||$1~/0\.5/||$1~/1\.0/||$1~/1\.5/
so i get this:
"
0.0021 etc
0.0123 etc
0.5324 etc
0.5434 etc
1.0344 etc
1.5345 etc
1.5632 etc
"
What I can't accomplish, is to keep only the fisrt occurrence of each ".0" or ".5" pattern.
I found in the gnu manual that to keep exaclty n occurrences of the expression r in awk, you should add {n} right after (r{n}). So, I tried it with {1} after the expression and it didn't compile. I also tried it with backshlashes and put it before or somewhere inside the expression, but no luck.
Do you have any idea what's wrong?
Thanx in advance.