以下script.bin通过tee行追加到file.log(来自我的bash脚本)
IP=xxx.xxx.xxx.xxx
./script.bin | tee -a file.log
Run Code Online (Sandbox Code Playgroud)
我的目标是在tee创建的每一行之后添加"IP = 127.0.0.1"(IP地址为示例)
注意:我们无法修改script.bin以添加"IP = 127.0.0.1" - 因为它的二进制文件
我需要建议如何在file.log中创建的每一行之后添加IP = xxx.xxx.xxx.xxx
乔恩
cat file.log (the ordinary file.log)
start_listen_to_port - 5500
start_listen_to_port - 5400
start_listen_to_port - 5410
.
.
.
cat file.log ( the right log.file syntax )
start_listen_to_port - 5500 IP=127.0.0.1
start_listen_to_port - 5400 IP=127.0.0.1
start_listen_to_port - 5410 IP=127.0.0.1
.
.
.
Run Code Online (Sandbox Code Playgroud)
ste*_*tew 10
./script.bin | sed "s/\$/ IP=$IP/" | tee -a file.log
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8492 次 |
| 最近记录: |