Create a file in your linux using the following command
shell> touch helloworld.rb
or open up vi editor with the name of the new file to be created
shell> vi helloworld.rb
In the file that is opened, write your code by taking the following steps
1. Press i key on your keyboard
2. You will enter the write mode and now you can write your text [puts "Hello World"]
Now save and close down the file by taking the following steps
1. Press ESC key on your keyboard
2. Write :wq and Press Enter
The file will get saved and you will be thrown out to the shell prompt.
On shell prompt write the following command
shell> ruby helloworld.rb
You will shown the following output
Hello World
Thats it to writing your first ruby script and executing it on linux.
Go back to the table of contents for 'Ruby on Linux'
No comments:
Post a Comment