title: How can I add the current date or time to end of each line in file?
body: <p>I have a file called <code>data.txt</code>.</p>
  
  <p>I want to add the current date, or time, or both to the beginning or end of each line.</p>
  
  <p>I have tried this:</p>
  
  <pre><code>awk -v v1=$var ' { printf("%s,%s\n", $0, v1) } ' data.txt &gt; data.txt
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>sed "s/$/,$var/" data.txt
  </code></pre>
  
  <p>Nothing works.</p>
  
  <p>Can someone help me out here?</p>