Passing arguments to an interactive program non-interactively

前端 未结 6 982
一生所求
一生所求 2020-11-22 05:06

I have a bash script that employs the read command to read arguments to commands interactively, for example yes/no options. Is there a way to call this script i

6条回答
  •  难免孤独
    2020-11-22 05:37

    You can also use printf to pipe the input to your script.

    var=val
    printf "yes\nno\nmaybe\n$var\n" | ./your_script.sh
    

提交回复
热议问题