bash read不等待输入

时间:2017-06-01 09:46:14

标签: bash ssh

我有这段代码:

#!/bin/bash
for some_host in $(cat some_list); do
    echo $some_host
    ssh $some_host sudo cat /etc/some.conf |grep -i something_to_grep
    printf "\nPut the input: " read some_input
    echo $some_input
    
done

当我运行它时,它会继续而不等待我的输入。我需要复制/过去ssh输出的东西以便采取进一步行动:/

1 个答案:

答案 0 :(得分:2)

更改

printf "\nPut the input: " read some_input

read -p "Put the input: " some_input

实施例

for host in '1.1.1.100' '1.1.1.101' '1.1.1.102'
do
    read -p "Enter your input for ${host} " host_input
    echo "${host} says ${host_input}"
done