bash – 暂停Shell脚本直到在循环中按Enter键

前端之家收集整理的这篇文章主要介绍了bash – 暂停Shell脚本直到在循环中按Enter键前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我在读文件

示例脚本

while read file
do
temp = $(echo $file)
read -p "Press Enter to continue"
echo $temp
done < test.txt

我想暂停脚本,直到我按ENTER键

默认情况下读取标准输入的读取,重定向文件,因此它从文件获取行.您可以重定向回终端:
read -p "Press Enter to continue" </dev/tty

另一种选择是使用不同的FD进行文件重定向

while read -u 3
do
    ...
done 3< test.txt
原文链接:https://www.f2er.com/bash/385105.html

猜你在找的Bash相关文章