Running Scripts
In this page:
Running Scripts
A Ruby script is run with ruby filename.rb from the command line, executing every statement top to bottom. This is the standard way to run a complete Ruby program, as opposed to experimenting interactively in IRB. The .rb extension is a convention, not a strict requirement.
Note: ruby -c filename.rb checks a script's syntax without actually running it.
Example: Running Scripts
# Run a Ruby script from the command line
ruby hello.rb
# Check syntax without running it
ruby -c hello.rb
⚠️ Run this command in your terminal.
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: