linux – tee命令无法正常工作(带有read和echo)
发布时间:2020-12-30 11:34:23 所属栏目:Linux 来源:互联网
导读:脚本和输出如下: 脚本: #!/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
脚本和输出如下: 脚本: #!/bin/bash #tee_with_read.sh function 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.sh Enter input : ***This should be printed first,but it is not*** "My Input" You entered : "My Input" 我正在尝试将输出附加到logfile. 我在Windows 10上使用Git Bash版本3.1.23. 解决方法read -p将它的输出写入stderr,echo正在写入stdout. stdout通常是缓冲的,而stderr则没有,因此在stdout之前看到stderr事件的情况并不少见.如果你喜欢做回声“字符串”>& 2你可以让你的回声也转到stderr,或者你可以在unbuffer命令或类似的工具中运行它,如果你有它们可用的话 (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- linux – 使用inittab确保sshd(和其他重要项)仍在运行 – 有
- 在ARM处理器上运行嵌入式Linux的最低配置?
- linux – 在Ubuntu上安装Gnuplot 5.0
- linux – ssh multi-hop上的“bash:nc:command not found
- 在linux上安装php zip
- gdb – 我有一个没有使用调试符号构建的可执行文件的核心转
- php – 如何从pdf中提取文本图层和背景图层?
- linux – 禁用apache日志记录到access.log [已关闭]
- linux定时任务之crontab
- SAP Java:java.lang.NoClassDefFoundError:com.sap.conn.