Pipe shell output to ruby -e?

X

x1

I know this has been done before but search yields nothing :-\

Just wondering how you can pipe output to ruby -e? I tried this but
it doesnt work :-(

#### borked
echo "hello" |ruby -e 'puts ARGV.to_s'



Thanks for any help you may be able to offer.
 
B

Bill Kelly

From: "x1 said:
Just wondering how you can pipe output to ruby -e? I tried this but
it doesnt work :-(

#### borked
echo "hello" |ruby -e 'puts ARGV.to_s'

A couple possibilities:

echo hello | ruby -e "puts gets"
echo hello | ruby -e "puts ARGF.read"

ruby -e 'puts ARGV.to_s' `echo hello`


Hope this helps,

Bill
 
E

EB

x1 said:
I know this has been done before but search yields nothing :-\

Just wondering how you can pipe output to ruby -e? I tried this but
it doesnt work :-(

#### borked
echo "hello" |ruby -e 'puts ARGV.to_s'

echo "hello" | xargs ruby -e 'puts ARGV.to_s'

will also work.

Cheers,

eb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,133
Latest member
MDACVReview
Top