how do you do this with ruby?

C

casioculture

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?
 
P

pat eyler

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>
 
R

Rob Rypka

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?

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
 

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

No members online now.

Forum statistics

Threads
473,786
Messages
2,569,626
Members
45,328
Latest member
66Teonna9

Latest Threads

Top