How to run Ruby code from terminal?

前端 未结 2 507
半阙折子戏
半阙折子戏 2021-01-30 03:53

I need to run a few lines of Ruby code from terminal, but I can\'t find the needed parameter for it.

Can you explain how to do this?

2条回答
  •  佛祖请我去吃肉
    2021-01-30 04:14

    You can run ruby commands in one line with the -e flag:

    ruby -e "puts 'hi'"
    

    Check the man page for more information.

提交回复
热议问题