Created
January 4, 2010 02:32
-
-
Save sweemeng/268248 to your computer and use it in GitHub Desktop.
a awk script to print the field number with empty line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/awk -f | |
#will fail with several case, still investigating | |
BEGIN{ | |
print "begin"; | |
} | |
{ | |
count=0; | |
for(f=1;f<=NF;f++){ | |
if($f==""){ | |
if(count==0){ | |
arr[count]=f; | |
} | |
else{ | |
exist=0; | |
for(i=0;i<=count;i++){ | |
if(arr[i]==f){ | |
exist=1; | |
} | |
} | |
if(exist==0){ | |
arr[count]=f; | |
} | |
} | |
count++; | |
} | |
} | |
} | |
END{ | |
for(j=0;j<=count;j++){ | |
print "empty field: " arr[j]; | |
} | |
print "completed"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment