这个 read命令为什么没执行
时间:2011-04-10
来源:互联网
#!/bin/bash
while read line
do
read -p "Is this word $line correct:[y|n]" answer
case $answer in
y)
continue;;
*)
read -p "please input the correct word:" string
sed 's/$string/$line/g' >>a.txt
esac
done<a.txt
从a.txt中每读出一行 就询问单词是否正确 回答为 y 就继续读取 否则输入正确单词 在a.txt中用正确的单词取代错误的单词
上面的脚本 在
read -p "Is this word $line correct:[y|n]" 执行时就有问题 提示Is this word $line correct:[y|n]语句没出来 请教为啥子
while read line
do
read -p "Is this word $line correct:[y|n]" answer
case $answer in
y)
continue;;
*)
read -p "please input the correct word:" string
sed 's/$string/$line/g' >>a.txt
esac
done<a.txt
从a.txt中每读出一行 就询问单词是否正确 回答为 y 就继续读取 否则输入正确单词 在a.txt中用正确的单词取代错误的单词
上面的脚本 在
read -p "Is this word $line correct:[y|n]" 执行时就有问题 提示Is this word $line correct:[y|n]语句没出来 请教为啥子
作者: 123freebird 发布时间: 2011-04-10
回复 123freebird
try:
复制代码
try:
- #!/bin/bash
- for line in `cat file`
- do
- read -p "Is this word $line correct:[y|n]" answer
- case $answer in
- y)
- continue;;
- *)
- read -p "please input the correct word:" string
- sed 's/$string/$line/g' >>a.txt
- esac
- done
作者: yinyuemi 发布时间: 2011-04-10
回复 yinyuemi
谢谢
但是 while不是也可以循环从文件 读取吗 我那种写法 为啥不对呢
谢谢
但是 while不是也可以循环从文件 读取吗 我那种写法 为啥不对呢
作者: 123freebird 发布时间: 2011-04-10
do 与done之间的read后面加上 <&0 试试.
作者: 惟吾无为 发布时间: 2011-04-10
作者: yinyuemi 发布时间: 2011-04-10
回复 惟吾无为
谢谢 加了<&0不行
不过你给了思路 我换成</dev/tty就可以了
难道 read -p中 这个read 它还认为是从a.txt中读取么 所以 read -p执行失败?
谢谢 加了<&0不行
不过你给了思路 我换成</dev/tty就可以了
难道 read -p中 这个read 它还认为是从a.txt中读取么 所以 read -p执行失败?
作者: 123freebird 发布时间: 2011-04-10
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28