<div dir="ltr">Actually, use this in place of the first line of the script I sent you:<div><br></div><div><div>#!/usr/bin/env ruby -w</div></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Nov 12, 2013 at 2:20 PM, Doug Hall <span dir="ltr"><<a href="mailto:doughalldev@gmail.com" target="_blank">doughalldev@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>#!/usr/bin/env ruby -i</div><div># Print all the lines from STDIN, prepended with the current time</div><div>ARGF.each_line do |line|</div><div> puts Time.now.to_s + ":" + line</div><div>end</div>
<div><br></div><div>-------</div><div><br></div><div><br></div><div>Assuming you have ruby installed, create a file with the above contents. I called it in_timestamped.rb. Change it to an an executable :</div><div><br></div>
<div>chmod +x in_timestamped.rb</div><div><br></div><div>Then, make sure it's installed into a directory in your $PATH.</div><div><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 12, 2013 at 1:58 PM, Ed Cashin <span dir="ltr"><<a href="mailto:ecashin@noserose.net" target="_blank">ecashin@noserose.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I do happen to know of one, but it's by Dan J. Bernstein. That sometimes means it's of uncommonly high quality and careful design but low user convenience.<div>
<br></div><div>Usually the resolution is to do everything the way DJB thinks things should be done. Then it's convenient and reliable. But it requires the user to adjust behavior and/or expectations. In this case, tai64n does what you ask for, but the timestamp is not probably anything you'd want to read. So tai64nlocal converts it. Weird, but not carelessly designed.</div>
<div><br></div><div><a href="http://cr.yp.to/daemontools/tai64n.html" target="_blank">http://cr.yp.to/daemontools/tai64n.html</a><br></div><div><a href="http://cr.yp.to/daemontools/tai64nlocal.html" target="_blank">http://cr.yp.to/daemontools/tai64nlocal.html</a><br>
</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Tue, Nov 12, 2013 at 1:34 PM, Scott Plante <span dir="ltr"><<a href="mailto:splante@insightsys.com" target="_blank">splante@insightsys.com</a>></span> wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div><div style="font-size:12pt;font-family:arial,helvetica,sans-serif"><font face="arial, helvetica, sans-serif" size="3">Does anyone happen to know of a command line tool that will read lines from standard input and write them to std out, pre-pending a timestamp? I have a process that emits messages to std out periodically as it processes and I'd like to write that to a log file, but with a time at the start of the line. I could do it with a script but a nice little command would be better, if it exists. </font><div style="font-size:12pt;font-family:arial,helvetica,sans-serif">
<br></div><div style="font-size:12pt;font-family:arial,helvetica,sans-serif">I'm looking for something that would perform the function of this script, maybe with an option for format:</div><div><font face="arial, helvetica, sans-serif"><br>
</font></div><div><font face="courier new, courier, monaco, monospace, sans-serif">while read line; </font></div><div><font face="courier new, courier, monaco, monospace, sans-serif">do </font></div><div><font face="courier new, courier, monaco, monospace, sans-serif"> echo $(date +"%D %T") "$line"; </font></div>
<div><font face="courier new, courier, monaco, monospace, sans-serif">done<span><font color="#888888"><br></font></span></font><span><font color="#888888"><div style="font-size:12pt;font-family:arial,helvetica,sans-serif">
<br></div><div style="font-size:12pt;font-family:arial,helvetica,sans-serif">Scott</div><br></font></span></div></div></div><br></div></div><div>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org" target="_blank">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br></div></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br> Ed Cashin <<a href="mailto:ecashin@noserose.net" target="_blank">ecashin@noserose.net</a>><br> <a href="http://noserose.net/e/" target="_blank">http://noserose.net/e/</a><br>
<a href="http://www.coraid.com/" target="_blank">http://www.coraid.com/</a>
</font></span></div>
<br>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org" target="_blank">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br></blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>