小编ss0*_*005的帖子

tee命令无法按预期工作(带有读取和回显)

脚本和输出如下:

脚本:

#!/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
Run Code Online (Sandbox Code Playgroud)

输出:

$ ./tee_with_read.sh
Enter input : ***This should be printed first, but it is not***
"My Input"
You entered : "My Input"
Run Code Online (Sandbox Code Playgroud)

我正在尝试将输出附加到logfile.但是正如你在输出中所看到的那样,似乎第一次读取被剔除,然后是回声,这不是预期的.

我在Windows 10上使用Git Bash版本3.1.23.由于此版本中没有命名管道,我不能使用命名管道进行日志记录.

unix linux bash

6
推荐指数
1
解决办法
861
查看次数

标签 统计

bash ×1

linux ×1

unix ×1