Hello World as a Self-Executable Fileusing Shebang Unix-like operating systems only

suggest change

You 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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents