<p dir="ltr">Change the ruby script. Ruby has a var that defines the name of the current file (ARGF.filename) and you can just do something like,</p>
<p dir="ltr">puts "#{ARGF.filename}:#{output}" if output =~ /pattern/</p>
<p dir="ltr">Jacon</p>
<div class="gmail_quote">On Sep 16, 2012 5:30 PM, "David L. Anselmi" <<a href="mailto:anselmi@anselmi.us">anselmi@anselmi.us</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sean LeBlanc wrote:<br>
> I have a Ruby script that takes as input either:<br>
><br>
> 1. 1-N command line args, assumes those are filenames, and iterates over<br>
> those, translating the files into a readable format - writing on STDOUT.<br>
> 2. If no args, read STDIN and do the same with that stream of data.<br>
><br>
> find . -name * -print | xargs ./myscript.rb | grep "asearchstring"<br>
><br>
> And that's all well and good. Now, I want to know what file(s) I get a<br>
> hit in.<br>
<br>
Since you don't seem to care that all the inputs go to the same output you could prepend each line<br>
with the file name.<br>
<br>
Your script could send each file name to stderr before processing it. That only really works for<br>
screen output and isn't the Unix Way.<br>
<br>
Your script could send each file name to stdout before processing it and then your grep could<br>
include something that works on the file name lines:<br>
... | egrep "(file:|asearchstring)"<br>
<br>
Your script could produce an output file for each input file and then grep would work as usual (then<br>
to pipe to it you'd write the file names to stdout and go through xargs again).<br>
<br>
HTH,<br>
Dave<br>
_______________________________________________<br>
clue mailing list: <a href="mailto:clue@cluedenver.org">clue@cluedenver.org</a><br>
For information, account preferences, or to unsubscribe see:<br>
<a href="http://cluedenver.org/mailman/listinfo/clue" target="_blank">http://cluedenver.org/mailman/listinfo/clue</a><br>
</blockquote></div>