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
cat $1 | awk '
BEGIN {
functionNameFile="";
}
/^short/ {
/* assumes return type of short */
/* assumes space between return type, function name, and parm list */
functionNameFile=$2.".c";
print $0 > functionNameFile;
}
/^\}/ {
print $0 >> functionNameFile;
functionNameFile="";
next;
}
{
if(functionNameFile != "") {
print $0 >> functionNameFile;
}
}
'
Labels: awk
echo $PATH | gawk -F':' '{
for(i=1; i<NF; i++) {
if(i) {
printf (":");
}
printf("%s", $i);
}
}'
Labels: awk