Ruby Document Center-Learning to start _ruby topics
Source: Internet
Author: User
First, you have to check if Ruby is installed. In the shell prompt entered prompt (here is expressed as "%", so don't typing%), typing
% Ruby-v
(-V tells the interpreter to print out Ruby version) and then knocks in the carriage. If Ruby is installed, you will see a message similar to the following:
% Ruby-v
Ruby 1.6.6 (2001-12-26) [I586-linux]
If Ruby is not installed, you can have the administrator install it, or you can do it yourself, Ruby is a free software that does not have the installation or use restrictions.
Now, let's play with Ruby. You can place a Ruby program directly on the command line with an-e argument:
^d refers to control-d. Above is the case under UNIX. If you use DOS, that's it:
c:\ruby> Copy con:test.rb
print "Hello world\n"
^z
C:\ruby> type TEST.RB
print "Hello world\n"
C:\ruby> Ruby Test.rb
Hello World
When writing more practical code than this, you will want to use a real text editor!
Something incredibly complex and useful can be done with a single line of commands. For example, this gadget replaces Foo in all C-source programs and header files in the current directory with bar and appends the original file with a ". Bak" Backup:
% Ruby-i.bak-pe ' Sub ' foo ', ' Bar ' ' *. [CH]
This program is similar to the Cat command under UNIX (but slower than cat):
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.