Reputation: 71
AWK: How to supress default print Following awk if statement always prints $0. How to stop it from doing so
( nodeComplete && count )
{
#print $0
#print count;
for (i = 0; i < count; i++) {print array1[i];};
nodeComplete=0;
count=0;
}
Upvotes: 3
Views: 665
Reputation: 133700
Welcome to SO, try changing your braces {
position and let me know if this helps.
( nodeComplete && count ){
#print $0
#print count;
for (i = 0; i < count; i++) {print array1[i];};
nodeComplete=0;
count=0;
}
Explanation of above change:
logic behind this is simple { next to condition means coming statements should be executed as per condition. If you put them in next line then it will all together a different set of block and condition will be a different block. So if condition is TRUE then it will print complete line since { is altogether a separate block.
Upvotes: 1