[SLUG] grep sed

john at johnallsopp.co.uk john at johnallsopp.co.uk
Tue Feb 28 15:22:12 GMT 2006


> On Mon, Feb 27, 2006 at 04:15:06PM GMT, John Allsopp wrote:
>> > john at johnallsopp.co.uk wrote:
>> >> grep -l "+44 123 4567" *.php | xargs sed 's/+44 123 4567/+44 765
>> >> 4321/g' | tee out.txt
>
> Al said: John, I can see how you got this to work, but I'm uncertain
about what
> you were trying to do with the '| tee out.txt' bit.  I can see how
> you'd
> use grep -l to find all the files containing your string before
> passing
> that list to xargs and doing some sed magic to change the old to new
> numbers.  Could you explain where 'tee' fits in please?

I've always been irritated by the > out.txt to redirect the output to
a file, whereupon you can't see what's being output. | tee out.txt is
a T junction, a stream splitter: the output goes to the file, but it
also goes to stdout too.

Lovely jubbly.

J




More information about the Scarborough mailing list