Can I use ls command or wget gnu software inside a Ruby script? Actually, can I use Ruby instead of Bash , and use all of Linux commands and Gnu Software ?

  • 1
    actually , i love ruby and Gnu/Linux , but not bash ! . so i want to finding a solution for don't using bash. – watermelon Feb 6 '17 at 13:11
  • Hi! Is your question "can I use Ruby as a shell instead of more typical shells like bash"? Or is it "can I replace my shell scripts with Ruby scripts"? – dhag Feb 6 '17 at 13:59
  • @dhag , my question is "can i use Ruby as s shell instead of more typical shells like bash " – watermelon Feb 6 '17 at 16:33

There are Unix shells written in many popular languages, Ruby included. An example is rush (also described at http://rush.heroku.com/, which, hilariously, has misconfigured SSL). A few examples of its use, from the documentation:

Count the number of classes in your project using bash:

find myproj -name \*.rb | xargs grep '^\s*class' | wc -l

In rush, this is:


It could be debated how practical this is as a Unix shell, but it may be worth a try for a hard-core Ruby user.


I would suggest you to read this answer https://stackoverflow.com/questions/2232/calling-shell-commands-from-ruby

If you don't like bash you can use python, there is also a program called iPython which emulate shell but using python syntax.



x = %x(your command goes here)

if you need the output of the command in a variable, or

system(your command goes here)

if you want the output of the command be displayed on the screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.