From: Dossy Date: 2002-06-14T09:27:47+09:00 Subject: Re: UNIX pipes On 2002.06.14, David Douthitt wrote: > I thought I could do: > > @snaptime = `/usr/contrib/bin/gunzip -lv #{file} | /usr/bin/sed 's/^[^ ]* [^ ]* \(... .. ..:..\).*/\1/'`.chomp > p @snaptime > > ...and it should (to me, anyway) return: > > "Jun 12 13:54" > > ...instead of the odd result of: > > "\001" The \001 is probably happening because the \1 in your sed pattern is getting turned into a \001 by Ruby, instead of getting passed to sed as the string "\1" ... Try: @snaptime = `/usr/contrib/bin/gunzip -lv #{file} | /usr/bin/sed 's/^[^ ]* [^ ]* \(... .. ..:..\).*/\\1/'`.chomp Escape the \ of \1 as \\1. > What's the accepted way to use a UNIX pipe? I wound up using Ruby > commands instead of sed... Why use sed when Ruby already has regex? I'd certainly just take the output of gunzip and process it in Ruby rather than with another process (sed). -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)