Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how do you do this with ruby?

0 views
Skip to first unread message

casioc...@gmail.com

unread,
Nov 4, 2005, 2:54:00 PM11/4/05
to

In bash, you'd do this with the perl interpreter

Issue the perl command via -e switches on the shell command line:
perl -e 'print "Hello, world\n"'

or

Pass your script to Perl via standard input:
echo "print 'Hello, world'" | perl -

How would you do the above with the ruby interpreter in bash?

pat eyler

unread,
Nov 4, 2005, 3:06:42 PM11/4/05
to
pate@linux:~/lang/ruby> echo "puts 'hello world'" | ruby -
hello world
pate@linux:~/lang/ruby> echo "puts 'hello world'" | ruby
hello world
pate@linux:~/lang/ruby> ruby -e "puts 'hello world'"
hello world
pate@linux:~/lang/ruby>


--
thanks,
-pate
-------------------------


Rob Rypka

unread,
Nov 4, 2005, 3:07:56 PM11/4/05
to

s/perl/ruby

% ruby -e 'print "Hello, world\n"'
Hello, world
% echo "puts 'Hello, world'" | ruby -
Hello, world

I changed the command in the previous one because zsh cuts off the
last line for me if there's no newline, but you get the point.

The dash isn't necessary in the second example:

% echo "puts 'Hello, world'" | ruby
Hello, world

--
Rob


0 new messages