2010-10-12 84 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...