1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

7.2 Simple Programming under Linux
Learn advanced Linux commands
 Related Resources
• Linux Newbie Administrator Guide
• 0. Linux Benefit
• 1. Before Installation
• 2. Linux Resources/Help
• 3. Basic Operations FAQ
• 4. Newbie Admin FAQ
• ~ 4.1 Lilo
• ~ 4.2 Drives
• ~ 4.3 X-Windows
• ~ 4.4 Configurations
• ~ 4.5 Networking
5. Shortcuts / Commands
• 6. Linux Applications
• 7. Learn Linux Commands
• A. How to Upgrade Kernel?


A purely object-oriented scripting language. This language is a relative newcomer, but it is rapidly gaining popularity, and may well be the flavour of the future of programming.

To write a simple program in ruby, I open my favorite text editor and start a program with the following first line:

Here is an example of a program that I wrote to help me understand the basics of the ruby language:

#This is a comment
 a = Array.new
 print "Please enter a few words (type EXIT to stop):\n"

 i = 0
 while enterWord = STDIN.gets
   if enterWord == "EXIT"
   a[i] = enterWord
   i += 1

#sort the array
for i in 0...a.length-1 do
  for j in i+1...a.length do
    if a[j] < a[i]
      tmp = a[i]
      a[i] = a[j]
      a[j] = tmp

#Output the results
print "You entered "  + a.length.to_s + " entries.\n\n"
for i in 0...a.length do
  print "Entry " + (i+1).to_s + ": "+ a[i] + "\n"

I save my ruby script to file "myprogram". To execute it, I need to type on the command line:

Next > Back to "Learn Linux Commands"

Can't find what you are looking for?
Search the

Stay up-to-date!
Subscribe to the Linux free newsletter.

Explore Linux
By Category
    linuxLinuxcomputeTechb0502bb1540001006c84963cb0502bb1540002006c818e0ahttp://linux.about.comod526F6F74132058liveGary Newelllinuxguide3TO004KpzNIP11970-01-0110/od/index.htm0526F6F741approved/od
  1. About.com
  2. Tech
  3. Linux

©2016 About.com. All rights reserved.