any way to create an 'executable' file in ruby so you can run file.rb with ./file
I know you can just run ruby files ruby filename.rb
I also want to be able to send arguments so ./file argument_1 argument_2
#! /usr/bin/env ruby to your first line of file.rb file.$ chmod +x file.rb$ ./file.rbuse ARGV.
#! /usr/bin/env ruby
puts " parameter0 is: #{ARGV[0]}"
puts " parameter1 is: #{ARGV[1]}"
output:
$ ./test.rb a b
parameter0 is: a
parameter1 is: b
.rb filefor more details, refer to: https://techforluddites.com/windows-10-change-the-default-programs-for-opening-files/
#!/usr/bin/env ruby\n p 'hi!'then runchmod 2775 ./file.txtthen you can run./file.txtand the output will be"hi!"