开发者

append string after each line from pipe line

the following script.bin append by tee lines to file.log (from my bash script)

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

my target is to add the "IP=127.0.0.1" after each line that created by tee (the IP address is example)

remark: we can't modify the script.bin in order to add the "IP=127.0.0.1" -because its binary file

I need advice how we can to add IP=xxx.xxx.xxx.xxx after each line that created in file.log

Jon

开发者_Go百科
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
.
.
.


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


Pipe it through sed first to replace end-of-line with the ip

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜