Skip to content

Instantly share code, notes, and snippets.

@sweemeng
Created January 4, 2010 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sweemeng/268248 to your computer and use it in GitHub Desktop.
Save sweemeng/268248 to your computer and use it in GitHub Desktop.
a awk script to print the field number with empty line
#!/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