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:

  1. How many times a given function was called.
  2. At what position actual data occurred.

I created a stub function of the original offending function that logged to a file what # call this was and the data passed. Then I copied the offending functions’ caller and substituted offending function calls using this script, which quotes all passed parameters (note: already quoted parameters would need a little more work):

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; }

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • StumbleUpon
  • Tumblr
  • TwitThis
  • FriendFeed
  • Netvibes
  • Ping.fm
  • Posterous
  • Technorati
  • Tipd
  • Twitter
  • Yahoo! Buzz