Awk script to quote all parameters for a given function name.
Posted on | June 10, 2007 | No Comments
I was trying to maintain a program that wrote 200+ lines to a single file, using a single repeated function call–many of which had all NULL parameters. There were also occasional loops involved. The data was position based, so NULL writes counted.I was just trying to figure out:
- How many times a given function was called.
- At what position actual data occurred.
BEGIN {
OFS=","
}
/repeated_function_name/{
for(i=1; i<=NF; i++)
{
if(i==1)
{
sub("[(]", "(\"", $i);
}
else
{
sub("^[ ]*","\"", $i);
}
if(i==NF)
{
sub("[)]", "\")", $i);
}
else
{
sub("[ ]*$", "\"", $i);
}
}
print (.*?)
next;
}
{ print (.*?); }
Category: awk
Comments
Leave a Reply


















