Bash script to format pmccabe output into a csv

#!/bin/sh
grep -r -l --include *.c --include *.h . > filelist
while read file; do
        OUTPUT=`pmccabe -F $file 2>/dev/null | sed -r -e "s/[\t\ ]+/,/g"|cut -d, -f1-5`
        FILENAME=`echo  $p | sed 's/.*\///'`
        echo $OUTPUT","$FILENAME","$file

done < filelist

Blog tags: 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <python> <c>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.