Questions tagged «user-input»

4
如何从管道读取用户输入?
假设我有一个文件confirmation.sh,其内容如下: #!/bin/bash echo -n "Are you sure [Y/n]? " read line case "$line" in n|N) echo "smth" ;; y|Y) echo "smth" ;; esac 并且我想通过以下方式运行此脚本: cat confirmation.sh | sh 我看到Are you sure [Y/n]?了,脚本被打断了。有什么问题?

2
逐行读取文件时请求用户输入
对于班级,我需要编写一个Bash脚本,该脚本将获取输出ispell,当我尝试在while循环内请求用户输入时,它仅将文件的下一行保存为用户输入。 我该如何在while循环中请求用户输入? #!/bin/bash #Returns the misspelled words #ispell -l < file #define vars ISPELL_OUTPUT_FILE="output.tmp"; INPUT_FILE=$1 ispell -l < $INPUT_FILE > $ISPELL_OUTPUT_FILE; #echo a new line for give space between command #and the output generated echo ""; while read line; do echo "'$line' is misspelled. Press "Enter" to keep"; read -p …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.