Bash 如何将键盘输入传递到linux命令?

Bash 如何将键盘输入传递到linux命令?,bash,Bash,我运行一个linux命令,有时要求用户输入(按1或2) 我总是想回答1,我怎样才能自动传递这个值呢?只是一个想法: yes 1 | command echo "1" | linux_command --with-arguments <&0 echo“1”| linux_命令——使用参数使用管道|操作符将一个命令的输出连接到另一个命令的输入 echo 1 | command 如果要对命令重复某些输入,可以使用yes。默认情况下,它会重复发送字符串“y”,但也会重复您选择的其他字

我运行一个linux命令,有时要求用户输入(按1或2)

我总是想回答1,我怎样才能自动传递这个值呢?

只是一个想法:

yes 1 | command
echo "1" | linux_command --with-arguments <&0

echo“1”| linux_命令——使用参数使用管道
|
操作符将一个命令的输出连接到另一个命令的输入

echo 1 | command
如果要对命令重复某些输入,可以使用
yes
。默认情况下,它会重复发送字符串“y”,但也会重复您选择的其他字符串

yes | cp * /tmp  # Answer "y" to all of cp's "Are you sure?" prompts.
yes 1 | command  # Answer "1" repeatedly until the command exits.