Add a line after each line from the pipeline line

the following script.bin add line by line tee to the .log file (from my bash script)

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

my goal is to add “IP = 127.0.0.1” after every line created by the tee (example IP address)

note: we cannot modify script.bin to add "IP = 127.0.0.1" - because its binary

I need advice on how we can add IP = xxx.xxx.xxx.xxx after every line created in the .log file

John

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
.
.
.
+3
source share
2 answers
./script.bin | sed "s/\$/ IP=$IP/" | tee -a file.log
+9
source

Swipe it through sed to replace ip end of line

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

Source: https://habr.com/ru/post/1769205/


All Articles