Bash - How to pass arguments to a script that is read via standard input

前端 未结 2 639
天涯浪人
天涯浪人 2021-01-31 14:40

I am trying execute a script from standard input and also pass arguments to it. Is there a way to do it?

Let\'s say that I have the following:

cat script         


        
2条回答
  •  长情又很酷
    2021-01-31 15:13

    After @ccarton's comment:

    cat script.sh | bash -s - arguments
    

    It's more portable than @Michael Hoffman's solution.

提交回复
热议问题