Linux has a feature where if the first line of an executable file starts with a no leading spaces and the name of a different executable then that executable will be run with the name of your original file as a command line parameter.
Run ruby script in bash.
Using wsl to run a shell script in windows 10 is a long process.
For more advanced tricks consult a more detailed guide to bash scripts on linux.
Run shell script on windows 10 with git bash.
This means you will have two files one bash script and one ruby script so actually this is surprisingly not easy and is why i m here.
You can also access your windows filesystem from within bash allowing you to work on the same set of files using your preferred windows tools or linux command line tools.
Here is an example of executing bash commands from inside ruby.
The script will run each command in turn.
Essentially if a command runs on the bash command line then it should work from inside ruby.
The script should ask you for your.
If you want something much quicker we recommend using git bash.
Compare the version number returned with the version number on the ruby download page.
Once there you can list files using the dir command on windows or the ls command on linux or os x.
In linux you can use the same approach as above.
By default the backtick and system approach both outputs the following.
Peter cooper demonstrates how to use the default text editor gedit in ubuntu 10 10 linux as a basic editor for ruby files and then how to run a ruby script at the terminal.
To run the test rb ruby script run the command ruby test rb.
If you need to run ruby code from within a shell script you could easily execute a ruby script with a simple bash command.
Go ahead and download git bash.
To verify that you have a current version of ruby run the command ruby v.
Your ruby files will all have the rb file extension.
You can now run bash scripts linux command line tools like sed awk grep and you can even try linux first tools like ruby git python etc.
Open a command line window and navigate to your ruby scripts directory using the cd command.
The same techniques will work in bash on ubuntu on.