title: Replace a specific line with formatted output in text file
body: <p>I have a program that outputs data to a textfile, but as of now it just concatenates on the end of the file.  I want to take some formatted output using printf and tell sed or awk to replace a certain line in that .txt.</p>
  
  <p>I've tried using several different methods.  Right now I'm trying to fine lines that start with $name and replace it with </p>
  
  <pre><code>printf "%-12s%-9s%-9s%-12s%-9s%-14s%-10s\n" "$name" "$quiz" "$hw" "$midterm" "$final"          
                    "$numberGrade" "$letterGrade"
  </code></pre>
  
  <p>i'm trying to use sed -i /^$name/\c ...    But I can't find a way to preserve the printf formatting if I set it to a variable.  Is there an easy way to do this?</p>