title: Prefixing logs with date in shell script
body: <p>I have a shell script with a lot of echo statements. I want to prefix each line of output with the time/date.</p>
  
  <p>So, I replaced every </p>
  
  <pre><code>echo "Some text1"
  echo "Some text2"
  </code></pre>
  
  <p>with</p>
  
  <pre><code>echo "`date +%y/%m/%d_%H:%M:%S`:: some text1"
  echo "`date +%y/%m/%d_%H:%M:%S`:: some text2"
  </code></pre>
  
  <p>This is rather ugly. Is there anyway to create an alias (or the analog to a #define in C), to make it cleaner.</p>
  
  <p>Obviously, doing something like:</p>
  
  <pre><code>DATE=`date +%y/%m/%d_%H:%M:%S`
  echo "$DATE:: some text1"
  echo "$DATE:: some text2"
  </code></pre>
  
  <p>... would not work, because in that case the DATE is only calculated once and each echo would have the same date.</p>
  
  <p>I am thinking about replacing every echo with a print function call, that does the prefixing. I want to know if anyone has any other/better ideas.</p>