脚本:
#!/bin/bash#tee_with_read.shfunction tee_test(){ echo "***This should be printed first but it is not***" read -r -p "Enter input : " echo "You entered : $REPLY"}tee_test | tee -a logfile
输出:
$./tee_with_read.shEnter input : ***This should be printed first,but it is not***"My input"You entered : "My input"
我正在尝试将输出附加到logfile.
但是正如你在输出中所看到的那样,似乎第一次读取被剔除,然后是回声,这不是预期的.
我在windows 10上使用Git Bash版本3.1.23.
由于此版本中没有命名管道,因此我无法使用命名管道进行日志记录.
如果你喜欢做回声“字符串”>& 2你可以让你的回声也转到stderr,或者你可以在unbuffer命令或类似的工具中运行它,如果你有它们可用的话
总结以上是内存溢出为你收集整理的linux – tee命令无法正常工作(带有read和echo)全部内容,希望文章能够帮你解决linux – tee命令无法正常工作(带有read和echo)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)