From: Ned Konz Date: 2002-06-14T09:11:40+09:00 Subject: Re: UNIX pipes On Thursday 13 June 2002 04:13 pm, 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" > > What gives? That's not a returned error code, is it? No, it's the \1 you asked for in the sed command... Ruby quoting doesn't work like shell quoting: single quotes inside double quotes or backticks don't mean anything special. So Ruby (not sed) got the \1, and decided it meant octal 1 (\001). > I tried "system()" but it doesn't return a string the way I want, > and it didn't work anyway. > > What's the accepted way to use a UNIX pipe? I wound up using Ruby > commands instead of sed... -- Ned Konz http://bike-nomad.com GPG key ID: BEEA7EFE