Hello World as a self-executable file (shebang, Unix-like systems only)
suggest changeYou can add an interpreter directive (shebang) to your script. Create a file called hello_world.rb which contains:
#!/usr/bin/env ruby
puts 'Hello World!'
Give the script executable permissions. Here’s how to do that in Unix:
$ chmod u+x hello_world.rb
Now you do not need to call the Ruby interpreter explicitly to run your script.
$ ./hello_world.rb
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents