2010-10-12 145 views
3

以下script.bin通过三通线追加到file.log(从我的bash脚本)追加字符串

IP=xxx.xxx.xxx.xxx 
    ./script.bin | tee -a file.log 

我的目标是添加了“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 
. 
. 
. 
+0

我需要建议我们如何才能添加IP = xxx.xxx更换结束线。在file.log中创建的每一行之后的xxx.xxx – jon 2010-10-12 18:33:10

回答

9
./script.bin | sed "s/\$/ IP=$IP/" | tee -a file.log 
1

它管道的sed先用IP

./script.bin | sed 's/$/ IP=127.0.0.1/' | tee...