My below code works fine if none of the columns has pipe as its content in it, If it has the pipe in any of the content then the value moves to the next column.
I wanted my code to work fine even if the column has pipe in it apart from the delimiter.
NOTE : If there is a pipe in the content apart from the delimiter it is been escaped by \(backslash)
#set -x
awk '
NR==1 {for (cc=1; cc<=NF; cc++) n[$cc]=$cc; t=$0; next;}
{
if ($1 != '0') c[1]++;
for (i=2; i<=NF; i++) if ($i != "NA" && $i != "null" && $i != "") c++;
}
END {
print t;
--NR
r="";
for (i=1 ; i<cc; i++) {
p=(c/NR)*100;
r=(i == 1) ? "" p : r OFS p;
}
print r
}
' FS="|" OFS="|" $1
Uhm where is the problem to try it with a short example like you have already given? It comes to principle about the problem, not to process an 8GB file...