Turn pseudo-enums expressed as #defines into strings.
cat $1 | awk '/#define/{
print "\t\tcase " $2 ":";
print "\t\t\tfprintf(out_csv_fp,\"," $2 "\");";
print "\t\t\tbreak;";
}' > out.txt
Labels: awk
Technology notes from an IT/software developer, mostly about the "shiny objects" in the web and software world.
cat $1 | awk '/#define/{
print "\t\tcase " $2 ":";
print "\t\t\tfprintf(out_csv_fp,\"," $2 "\");";
print "\t\t\tbreak;";
}' > out.txt
Labels: awk
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 $0
next;
}
{ print $0; }
Labels: awk